AnsweredAssumed Answered

Reclassifying raster - 0 to 1, 0 to NoData

Question asked by martinsirko on Nov 24, 2018

I am trying to accomplish quite simple operation, but it proved to be impossible using arcpy. 


I have an orthophoto where I want to set areas on the edges to NoData value. The final raster is supposed to be 8bit unsigned TIFF file, with JPG compression and RGB value 0,0,0 will be used to as NoData value.


1. Reclassify the whole image - set all 0 values in all RGB bands to 1

2. Clip the image, and the area outside of the clip will be set to RGB 0,0,0



I tried many different ways to do this to no avail. I found out that I could just use arcpy.CopyRaster_management and set arcpy.env.nodata = "MAP_UP", which should set all 0 to 1,  so there should be no 0 value in the resulting raster, but it is not working as described. The 0 values are set to noData and not changed to 1.


I have also try to reclassify and the image, which works on the each band, but this creates a 16BIT TIFFs with range of 1 to 255, just as I wanted, but then when I use arcpy.CompositeBands_management to join the different bands back to RGB image, the file will contain 0 values and also values which are higher than 255, which I do not understand why. Could be the compression algorithm, but I doubt it. Whatever I try, I cannot get it done.


I appreciate any suggestions. This shouldn't be so difficult to do. And why doesn't "map_up" setting doesn't work? Did I misunderstood it?


From the documentation:

NoData (Environment setting)—Help | ArcGIS for Desktop 

  • MAP_UP—The lowest value in the range will be promoted and the lowest will become NoData. If the data is unsigned, the value of zero will become one, the NoData value will be zero, and the rest of the values remain the same. If the data is signed, the lowest value in the range will be promoted and the lowest will become NoData. For example, with 8-bit signed integer data, -127 will become -126, and the NoData value will be -127.
  • MAP_DOWN—The NoData value will be the maximum value in the data range, the highest value of the data range will become one value less, and the rest of the values remain the same. For example, with 8-bit unsigned integer data, the NoData value will be 255, the value of 255 will become 254, and the rest of the values will remain the same.


Thank you