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)
-
Please always provide errors as text rather than pictures so that they are available to future searches by people who may have the same problem.PolyGeo– PolyGeo ♦2018年09月27日 23:17:14 +00:00Commented Sep 27, 2018 at 23:17
-
1It will work in script, but you need to use arcpy.Raster(rasterName) as argument.FelixIP– FelixIP2018年09月28日 00:12:50 +00:00Commented Sep 28, 2018 at 0:12
1 Answer 1
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
Explore related questions
See similar questions with these tags.