1

I'm trying to do Subtraction between two rasters. and I'm getting this error

000539 : Error message from Python.

Description The calculation used by the Calculate Field or Calculate Value tool is invalid. The error message provided will list the specific Python error.

Solution This error code covers a number of Python errors:

Example error 1: exceptions.TypeError: cannot concatenate 'str' and 'int' objects. The above is a Python-specific error. The calculation is attempting to add or concatenate a string and a number.

Example error 2: Invalid field shape@distance The above is an error using the geometry object. The distance method is not a valid method of the geometry object.

For specific Python issues, consult the external Python help for the version of Python you are using, or consult the Calculate Field or Calculate Value help for more information on these tools.

I could really use some more explanation..

2
  • Welcome to GIS:SE @יעל לרנרמן! Have you seen this forum page? A couple of suggestions was to make sure both rasters are in the same projection; and for simple subtraction of two rasters, you could use the ArcToolbox > Spatial Analyst Tools > Math > Minus tool.
    – Joseph
    Oct 25, 2019 at 11:33
  • 1
    Welcome to GIS SE. As a new user, please take the Tour, which explains how our Focused question/Best answer model operates. Copying the documentation into the question is a lot less useful than placing your own code which generated the error in the question. This would allow use to provide context.
    – Vince
    Oct 25, 2019 at 11:35

1 Answer 1

1

You are running some Python code (that you made in Modelbuilder, maybe) that is using the raster calculator. The raster calculator is not available in arcpy. See this from the ESRI website:

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.

And here is a link to your specific error code. You will need to do your subtraction using a minus function from the spatial analyst tools. Something like this:

outMinus = Minus(inRaster1, inRaster2) 
outMinus.save("C:/minus.tif")
4
  • thank you so much. can you be more detailed? what tool do i need to use? Nov 14, 2019 at 12:17
  • ArcToolbox - Spatial Analyst Tools - Math - Minus
    – GBG
    Nov 14, 2019 at 16:17
  • i get another problem can you help me please? > 000964 : Specified extent is invalid. Description This error occurs when you clip a raster dataset using an extent that doesn't overlap with the raster dataset. Solution Use an extent that overlaps with the input raster dataset to clip. Nov 19, 2019 at 18:27
  • Make sure that your polygon and your raster data are using the same coordinate reference system. Make sure that the polygon exists in the same location (overlaps) the raster dataset.
    – GBG
    Nov 20, 2019 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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