[GIS] Raster processing with Python or Arc raster calculator

arcgis-10.0pythonrasterraster-calculator

I have 4-band NAIP imagery that require the following processing steps:

  1. Convert to 8 bit unsigned B/W
  2. Reverse (note not inverse) the image, so that dark values appear
    light and light values appear dark. Moderate values should remain
    relatively unchanged.

Could someone please point me in the right direction for a Python or Arc raster calculator approach?

Best Answer

In python (with numpy, assuming "naip" is your 4 band image as a numpy array), the following will rescale your data to 0-255 in reverse:

rescaled=((naip - naip.max()) * -255 / (naip.max() - naip.min())).astype(numpy.uint8)

If your data is already >0 and <255 and you don't want to scale it from 0-255, but just reverse it:

reversed=((naip - naip.max()) * -1 + naip.min()).astype(numpy.uint8)

An ArcGIS raster calculator solution would be quite similar, though you would have to operate on the bands individually then combine them again afterwards.

Related Question