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)

SMiller
3,72611 silver badges22 bronze badges
asked Sep 27, 2018 at 22:11
2
  • 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. Commented Sep 27, 2018 at 23:17
  • 1
    It will work in script, but you need to use arcpy.Raster(rasterName) as argument. Commented Sep 28, 2018 at 0:12

1 Answer 1

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

answered Sep 27, 2018 at 22:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.