1

The following code subtract the minimum value of the raster from each cell value. Is there something wrong in it?

This error comes with it every time that i run...

Traceback (most recent call last):
  File "Z:\04 - Temp\Charles\NDVI_tempo\NDVI_py3.tbx#Script_NDVIpy3.py", line 39, in <module>
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sa\Functions.py", line 4246, in Minus
    in_raster_or_constant2)
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sa\Functions.py", line 4243, in Wrapper
    ["Minus", in_raster_or_constant1, in_raster_or_constant2])
RuntimeError:  ERROR 000732: Input Raster: Dataset 1536 does not exist or is not supported
Failed to execute (Script).

Actually, it does getting the minimum value, but it seems like it don't recognize it as a constant.

for tiff3 in rastersband3:

            path3 = env.workspace + "\\" + tiff3
            arcpy.CalculateStatistics_management(path3)
            Correcao1 = Minus(path3,(arcpy.GetRasterProperties_management(path3, "MINIMUM")))
  • Use os.path.join instead of + when you are combining paths and files – BERA Sep 28 '17 at 19:48
  • 1
    If you've set your workspace path3 is redundant, using the name of the raster automatically assumes that you're referring to the file in your env.workspace. The problem is that GetRasterProperties returns a ResultObject not an integer or float, try Minus(path3,(float(arcpy.GetRasterProperties_management(path3, "MINIMUM").getOutput(0)))) to get the value of the result as a floating point number and subtract from your raster file.. It's also a good idea to convert your path/filename into a raster object to use sa functions: Correcao1 = Minus(arcpy.Raster(path3)... – Michael Stimson Sep 28 '17 at 21:07
  • Use raster.minimum gis.stackexchange.com/a/192913/2856 – user2856 Sep 28 '17 at 22:57

Your Answer

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

Browse other questions tagged or ask your own question.