mayering

Failed to execute (ExtractByMask)

Discussion created by mayering on Mar 12, 2012
Latest reply on Mar 13, 2012 by mayering
Dear Forum,

I found a loop example here from the forum and modified for my case. Thanks for the previous Q/As.
what I am trying to do is:
1. read a list of ascii files
2. convert them to raster
3. clip raster file by a boundary mask
4. convert the clipped raster to polygon

I got an error message for 'extractbymask':
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000860: Input raster or feature mask data: is not the type of Composite Geodataset, or does not exist.
Failed to execute (ExtractByMask).

here is the code:
# ---------------------------------------------------------------------------
# convertions_loop.py
# Created on: Mon Mar 12 2012 04:31:41 PM
#   (generated by ArcGIS/ModelBuilder)
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

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

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")


# Set local variables
InAsciiFile = None
inDir = r"C://a//asc_annual_PDSI"
OutRaster = "C://a//raster_annual"
SRER_bound="C://Spatial//shape_files//bounds.shp"
OutClip="C://a//raster_annual_clip"
OutPolygon="C://a//polygon_annual"

for InAsciiFile in os.listdir(inDir):
    if InAsciiFile.rsplit(".")[-1] == "asc":
        print InAsciiFile
# Process: ASCIIToRaster_conversion
        outR= os.path.join(OutRaster,InAsciiFile.rsplit(".")[0])
        gp.ASCIIToRaster_conversion(os.path.join(inDir,InAsciiFile), outR, "INTEGER")

# Process: Extract by Mask...
        outC=os.path.join(OutClip,InAsciiFile.rsplit(".")[0])
        gp.ExtractByMask_sa(outR, SRER_bound, outC)

# Process: Raster to Polygon...
        outP=os.path.join(OutPolygon,InAsciiFile.rsplit(".")[0])                               
        gp.RasterToPolygon_conversion(outC,outP, "NO_SIMPLIFY", "VALUE")
-----------------------------------------
I tried to use:
SRER_bound="C://Spatial//shape_files//bounds"
but got the same error

Could anyone please help? Thanks.

Outcomes