tomas1

ArcGIS Pro RasterCalc Tool Map Algebra Expression Proper Syntax through code

Discussion created by tomas1 on Feb 2, 2017
Latest reply on Feb 8, 2017 by tomas1

I would appreciate some syntax assistance regarding how to build in code the map algebra syntax used by RasterCalc tool in ArcGIS Pro.  I have successfully implemented other Geoprocessing tools and was able to create the necessary args for required value array without much heartburn.

 

However, doing this for the RasterCalc Geoprocessing through code has proven elusive.  I have looked at the native tool in ArcGIS Pro. The tool appears to call for building a map algebra expression using an input raster and whatever calculation you wish to perform.  When I interactively use the tool, the desired syntax it produces is:

 

"sd_20170201" * 10000

 

raster calc tool ArcGIS Pro

 

 

I am able to run the tool interactively in ArcGIS Pro successfully. I thought this would be simple enough to build in code. Unfortunately, it has proven more involved.  I have build numerous versions ( fully qualifying the path to the input raster, various quoting strategies etc ) with no luck. 


Interestingly, when I returned to running the tool interactively through ArcGIS Pro to revisit this, when I first build the string through the tool interface,  I noticed the icon appeared adjacent to the Map Algebra expression label displays a red circle with a white X,  when I hover over the icon, it displays a same syntax error message I am encountering through code:  "ERROR 000989  Python Syntax Error: Parsing error SyntaxError: invalid syntax ( <string>, line 1)"

However, when  I click out of the expression textbox, the error icon disappears and the tool now likes the expression. 

 

After observing this, I thought that perhaps clicking out of the expression textbox might append a carriage return
to the string.  I tried the same approach in code, but it still threw the 989 error.  If anyone could provide the code version of building this seemingly simple string that the RasterCalc tool would like in code, I would be quite grateful.

Thanks for your time.

 

Cheers.

Outcomes