I have a workspace with NDVI rasters and another workspace with greyscale rasters. The rasters have the same name.
I want to reclassify the NDVI raster while also using the greyscale values in a function. Depending on the greyscale value, another reclass function should be used. So for every pixel, the correct function has to be found.
I need to use an if statement: if the greyscale raster cell value is high, another statement should be used but the code results in an error:
Invalid use of raster with Boolean operator or function. Check the use of parentheses where applicable.
arcpy.env.workspace = ndviws
ndvirasterlist = arcpy.ListRasters()
for rimage in ndvirasterlist:
ndvi_raster = arcpy.sa.Raster(rimage)
grey_raster = arcpy.sa.Raster(os.path.join(greyvalues,rimage))
if grey_raster <= 28523:
output_raster = Con(ndvi_raster < -0.0000006 * grey_raster + 0.3448,2,1)
if grey_raster >28523 and grey_raster < 50000:
output_raster = Con(ndvi_raster < -0.000009 * grey_raster + 0.437673,2,1)
if grey_raster >=50000:
output_raster = Con(ndvi_raster < -0.000007 * grey_raster + 0.5233,2,1)
output_raster.save(os.path.join(outputws,rimage))
edit: **edited so that there are now 3 if statements. Is this still working with con method?