Hi
I am using Geoprocessor in VB.NET and was trying to set the extent so my process is constraint by this extent.
When I set the property 'gp.SetEnvironmentValue("extent", "-450554.414000, -1154206.896400, -445014.414000, -1146626.896400");' and ran the GP processor, the output does not match the extent. The same is for Mask property.
I have tried it inside ArcGIS 10 by setting the environment and it works. I am not sure why setting the extent in the code for Geoprocessor is not working.
I Found two similar problems on Forum but without reply. Is this Bug in ArcObjects or what? Thanks a lot.
this is my code:
Function GP_ShpToRaster(pFeatureLayer As IFeatureLayer, pFieldNameHeight As String, pFieldNamePriority As String) As IRaster
Try
Dim pCellSize As Short = 20
Dim pOutRaster As IRaster
Dim gp As IGeoProcessor2 = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()
Dim util As IGPUtilities3 = New GPUtilitiesClass()
gp.OverwriteOutput = True
gp.ResetEnvironments()
gp.SetEnvironmentValue("extent", "-450554.414000, -1154206.896400, -445014.414000, -1146626.896400")
gp.SetEnvironmentValue("cellSize", 20)
gp.SetEnvironmentValue("mask", "B:\ISSOP\pokusneData\kysuce")
gp.SetEnvironmentValue("snapRaster", "B:\ISSOP\pokusneData\kysuce")
gp.SetEnvironmentValue("workspace", "B:\")
Dim parameters As IVariantArray = New VarArray
parameters.Add(pFeatureLayer)
parameters.Add(pFieldNameHeight)
parameters.Add("Output")
parameters.Add("")
parameters.Add(pFieldNamePriority)
parameters.Add(pCellSize)
Dim result As IGeoProcessorResult2
result = CType(gp.Execute("PolylineToRaster_conversion", parameters, Nothing), IGeoProcessorResult2)
Dim gpVal As IGPValue = result.GetOutput(0)
Dim inmemfc As String = gpVal.GetAsText()
Dim pRasDataset As IRasterDataset
pRasDataset = util.OpenRasterDatasetFromString(inmemfc)
Dim pRasterLayer As IRasterLayer
pRasterLayer = New RasterLayer
pRasterLayer.CreateFromDataset(pRasDataset)
pOutRaster = pRasterLayer.Raster
Return pOutRaster
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
End Function