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:
# ---------------------------------------------------------------------------
# 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

# 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"

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...
        gp.ExtractByMask_sa(outR, SRER_bound, outC)

# Process: Raster to Polygon...
        gp.RasterToPolygon_conversion(outC,outP, "NO_SIMPLIFY", "VALUE")
I tried to use:
but got the same error

Could anyone please help? Thanks.