Raster Calculator Expression

Discussion created by sindhua on Dec 29, 2013
Latest reply on Jan 8, 2014 by curtvprice
I wanted to add the height information of two rasters and create another raster using the raster calculator. In Desktop Raster Calculator Tool the expression for the Same is like this - "Raster1" + "Raster2".
I was trying to implement the same through coding in ArcGIS Engine using a Geoprocessing tool.

The code snippet is as follows:

Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
RasterCalculator rasterCalc = new RasterCalculator();
rasterCalc.expression = " '@D:\NewFolder:\Raster1.tif" + "+" + "@D:\NewFolder:\Raster2.tif' ";
rasterCalc.output_raster = "@D:\NewFolder:\Raster3.tif";

This is not getting executed and throws an error: HRESULT E_FAIL has been returned from a call to a COM component.

I think there is something wrong with the syntax of the expression.

Thanks in Advance for the help!