ExtractByRectangle Error

603
1
01-16-2013 02:06 PM
PabitraDash
New Contributor
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
Tags (2)
0 Kudos
1 Reply
JimCousins
MVP Regular Contributor
PK,
You create a variable called "ExtractedNLCDFileName" for your output raster, then as an argument for your out_raster you use "ExtractedNLCDFile".
Regards,
Jim
0 Kudos