LynneB

Raster Calculator Expression in C#

Discussion created by LynneB on Jul 29, 2013
Latest reply on Sep 27, 2013 by LynneB
I'm trying to use the RasterCalculator in C# (I'm not using python)

            string slopeRadiansRasterFilePath = Path.Combine(_options.OutputTmpWorkspaceName, "SlopeRadians");
            string formula = ('C:\Workspace\ForestGrids\R03\0310_SantaFe_smallTest\test\NnDemRasters.gdb\Elev' * 1.570796) / 90;

            RasterCalculator rasterCalc = new RasterCalculator();
            rasterCalc.expression = formula;
            rasterCalc.output_raster = slopeRadiansRasterFilePath;

Every time I run it I get a HRESULT error.

I can use the GP tool menu interface with the same raster and formula and it works fine.  Any ideas on what the format of the expression should be?  I've tried several different variations with single quotes, double quotes, square brackets, etc.

Outcomes