pkdash

ExtractByRectangle Error

Discussion created by pkdash on Jan 16, 2013
Latest reply on Jan 17, 2013 by jimcousins
I am trying to subset the NLCD dataset (.img format) using the geoprocessing ExtractByRectangle function and getting the following error:

Exception:ERROR 999998: Unexpected Error.
Failed to execute (ExtractByRectangle).

Here is my code:
import arcgisscripting
import arcpy

OriginalNLCDDataSetFile = r"E:\Scratch\USALandCoveData\nlcd2006_landcover_se5.img"
ExtractedNLCDFileName = "r"E:\Scratch\USALandCoveData\ExtractedWSNLCD.img"
BufferedWSFile = r"E:\temp\shapefiles\save\bufferedWatershed.shp"

gp = arcgisscripting.create()
# Check out any necessary licenses
gp.CheckOutExtension("spatial")

gp = arcgisscripting.create()
# Check out any necessary licenses
gp.CheckOutExtension("spatial")


Process: Extract by Rectangle
# Ref: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000002r000000.htm
#get the rectangular boundary of the WS shape file
shapeFileDesc = arcpy.Describe(BufferedWSFile)
wsBoundingBoxExtent = Extent(shapeFileDesc.extent.XMin, shapeFileDesc.extent.YMin, shapeFileDesc.extent.XMax, shapeFileDesc.extent.YMax)
gp.ExtractByRectangle_sa(OriginalNLCDDataSetFile, wsBoundingBoxExtent, ExtractedNLCDFile, "INSIDE")

I get the mentioned error when executing the highlighted statement above. I have done similar extraction coding and they all run fine. The only difference I know in this case is the file format and size. The original nlcd file is of .img format in this code example. The similar code to extract that has worked for me have file formats of .tif.

Would appreciate help.

PK

Outcomes