Python Toolbox Raster Parameter Error

Discussion created by BrokenLegMike on Apr 4, 2013
Latest reply on Apr 7, 2013 by curtvprice
Hey all, I borrowed a simple script I found online to clip a shapefile from the extent of a raster. It works perfectly from the ArcMap built in python command prompt. I modified is slightly to use in a tool. It's having issues accepting the raster (inraster) in:
extent = arcpy.Raster(inRaster).extent
I get the following error:

    extent = arcpy.Raster(inRaster).extent
TypeError: expected a raster or layer name

I'm using "Raster Layer" as my inRaster parameter type. The raster type I am using is an ERDAS IMAGINE .img file. I'm thinking it must be conflicting with the parameter type and the .img input raster, but I can't figure out what it is. As I mentioned, it worked from the command prompt, just not in the tool. Any suggestions are welcome.

Code is as follows:

import arcpy

inLines = arcpy.GetParameter(0)
inRaster = arcpy.GetParameter(1)
outRaster = arcpy.GetParameter(2)

pnt_array = arcpy.Array()
extent = arcpy.Raster(inRaster).extent

poly = arcpy.Polygon(pnt_array)

arcpy.Clip_analysis(inLines, poly, outRaster)