1

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 Sep 27 '18 at 23:17
  • 1
    It will work in script, but you need to use arcpy.Raster(rasterName) as argument. – FelixIP Sep 28 '18 at 0:12
5

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.