AnsweredAssumed Answered

Using Raster Calculator in Python Scripts

Question asked by qwerty@ on Jul 2, 2015
Branched to a new discussion

Hello,

 

I have a question regarding the using Raster Calculator expressions (+, -, *, /, log, sin) in Python Scripts.

 

I generated a model in Model Builder and exported them into Python Script. Then I implemented my script as a new tool in a toolbox. However, because in some steps in my model I used Raster calculator the tool does not work. I have an ERROR 000539: Error running expression: rcexec() As I have found in the error link, the problem is that Python Scripts are not using Raster Calculation Expressions.

 

Does anybody know if there is some way (other than this in the error link) to implement Raster Calculator expressions to Python Scripts?

 

Below are examples of expressions which I want to use in Python Script:

arcpy.gp.RasterCalculator_sa("(\"%2.tif%\") - (\"%3.tif%\")", v4_tif)

arcpy.gp.RasterCalculator_sa("Cos(\"%5.tif%\")", v6_tif)

 

Thanks in advance!

Outcomes