[GIS] ArcPy Raster Calculator error ” ‘str’ object has no attribute ‘save’ “

arcpyerror-000539raster-calculatorspatial-analyst

I converted a model into python script and tried to run it. It gave me an error when it gets to the raster calculator process.The message says "str" object has no attribute "save". See picture below.

My code here :

arcpy.gp.RasterCalculator_sa("\"%Reclass_Aspe5%\" + \"%Reclass_Slop7%\"", Output)

The expression: "%Reclass_Aspe5%" + "%Reclass_Slop7%"

The code it directly from ModelBuilder. Every other processes work out fine except raster calculator. Does anyone know what the problem is?

enter image description here
Error snippet:

ExecuteError: ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last): File "", line 1, in
File "", line 8, in rcexec AttributeError: 'str'
object has no attribute 'save'

Failed to execute (RasterCalculator)

Best Answer

Per the Esri documentation, this tool is not available in arcpy scripting:

http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/raster-calculator.htm

Note: The Raster Calculator tool is intended for use in the application only as a GP tool dialog box or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Spatial Analyst module.

Another resource (GeoNet) suggests using Map Algebra: https://community.esri.com/thread/56655

Related Question