I'm trying to execute the raster calculator function in VB.NET but I'm having trouble with the gp.execute
line. Sorry if the code is confusing, I'm fairly new to VB.net. I keep getting this error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ESRI.ArcGIS.Geoprocessor.dll
Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.
Here's my code. I thought it might have been the expression, but the error occurs at the execute command.
Private Sub ExecuteRasterCalc()
Dim raster1 As String = "T:\TeamProject\Group2\Ca Slope and Aspect\CA_ASP_RISK1.tif"
Dim raster2 As String = "T:\TeamProject\Group2\Ca Slope and Aspect\CA_SLP_RISK1.tif"
Dim raster3 As String = "T:\TeamProject\Group2\Ca Landcover Fire Intensity\CaFIRE_INTEN11.tif"
Dim raster4 As String = "T:\TeamProject\Group2\Ca Biomass Load\FUEL_LOAD1.tif"
Dim expression As String = "'" & raster1 & "'+'" & raster2 & "'+'" & raster3 & "'+'" & raster4 & "'"
Dim outputpath As String = "T:\TeamProject\Group2\Test.gdb\rastercalc"
Dim gp = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
gp.OverwriteOutput = True
gp.AddOutputsToMap = True
Dim parameters As IVariantArray = New VarArray
parameters.Add(expression)
parameters.Add(outputpath)
Dim result As IGeoProcessorResult = gp.Execute("RasterCalculator", parameters, Nothing)
End Sub