5

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?

  • Do you have the Spatial Analyst extension? You're out of luck if you don't as the Raster Calc requires it. As an alternative, QGIS has a raster calculator that can do what you need. – nagytech Jul 3 '12 at 12:49
  • Yes, I have the Spatial Analyst ext. – Aaron Jul 3 '12 at 12:52
  • And, just to be clear are you looking for information on how to do points 1 and 2, or information on how to do points 1 and 2 iteratively. – nagytech Jul 3 '12 at 12:54
2

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.

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.