1

I have two rasters, one with NDVI values, and one with greyscale values (=(red band + green band + blue band) / 3). The rasters have the same name.

I need to reclassify them in arcpy with the following formular:

if ndvivaluefrompixel >=-0.000005*greyscalepixelvalue+0.314367:
     return 2

if ndvivaluefrompixel <=-0.000005*greyscalepixelvalue+0.314367:
     return 1

I thought about using map algebra in arcpy but I'm not sure if it is possible to use such a function for reclassification?

Is this possible using map algebra/reclassify in arcpy? Of course this has to run in a loop then, so I have to use python.

Any idea?

6

This is how I would do it (it requires the Spatial Analyst extension which I think you have):

import arcpy
from arcpy.sa import *

arcpy.CheckOutExtension = "Spatial"

ndvi_raster = Raster("ndvivaluefrompixel")
grey_raster = Raster("grayscalepixelvalue")

output_raster = Con(ndvi_raster >= -0.000005 * grey_raster + 0.314367, 2, 1)
output_raster.save("C:/sapyexamples/output/outcon")

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.