Extract by mask

4026
2
Jump to solution
10-07-2013 08:35 AM
by Anonymous User
Not applicable
Original User: dk10

Hello,
I am trying to extract cells of a raster by using the Extract by Mask option (ArcGIS 10.0 SP4 - windows 7 Pro - SP1).  I have 2 raster datasets I want to process and I am getting different results on either.  The inputs are both 3 band, 8 Bit Unsigned Integer Rasters (TIFF format), cell size 0.1 meters, No Data Value of 256 and compression = None.  When I run the extract by raster arcgis process on them, 1 comes out fine - in the same format as the input, but the 2nd one comes out as a 16-bit unsigned integer TIFF - with a No Data value of 65536.  Any thoughts or ideas on why this is?  The script below is being used to (with indents of course):

import arcpy,sys,string,os
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

def extractds(i):
   arcpy.env.compression = "None"
   inws = "D:/Project/imageprocessing/test"
   outws = "D:/Project/imageprocessing/test"
   arcpy.env.workspace = outws
   clipds = "D:\\Project\\imageprocessing\\Data.gdb\\orthoclip"
   arcpy.env.snapRaster = inws + "\\" + str(i) + ".tif"
   if not arcpy.Exists(outws + "\\" + str(i) + "_extract.tif"):
      outextract = ExtractByMask(inws + "\\" + str(i) + ".tif",clipds)
      outextract.save(outws + "\\" + str(i) + "_extract.tif")


mylist = ['5058A','5058B']
for i in mylist:
   arcpy.AddMessage(str(i))
   extractds(i)



Screen shot of properties from input:
[ATTACH=CONFIG]28087[/ATTACH]
Screen shot of properties from output:
[ATTACH=CONFIG]28088[/ATTACH]
Thanks for any help!

Darryl Klassen
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: dk10

After much investigation, I have determined the cause of my issue.  Some of the images have value ranges from 0-255 i.e. the max 256 values in an 8bit raster, while others range from 1-255 - so only 255 values.  So when I run my extract and want to have a NoData value - the rasters that already have a maximum number of values for 8bit (256) default to 16bit because they need to include the NoData value therefore create 257 unique values which cannot be held in an 8bit raster.

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: dk10

After much investigation, I have determined the cause of my issue.  Some of the images have value ranges from 0-255 i.e. the max 256 values in an 8bit raster, while others range from 1-255 - so only 255 values.  So when I run my extract and want to have a NoData value - the rasters that already have a maximum number of values for 8bit (256) default to 16bit because they need to include the NoData value therefore create 257 unique values which cannot be held in an 8bit raster.
0 Kudos
curtvprice
MVP Esteemed Contributor
Some of the images have value ranges from 0-255 i.e. the max 256 values in an 8bit raster, while others range from 1-255 - so only 255 values.  So when I run my extract and want to have a NoData value - the rasters that already have a maximum number of values for 8bit (256) default to 16bit because they need to include the NoData value therefore create 257 unique values which cannot be held in an 8bit raster.


There is a new environment setting (10.1 and later) that may be helpful in this situation:

NoData (Environment setting)
0 Kudos