I have created a python script in ArcGIS 10.1. My first parameter type is a 'Feature Layer' set to as a multivalue input. I was running my script quite well off of data from one of my drives (my Y:drive), but then I tried use some data from another drive (my Z:drive) and am receiving an error:
ERROR 000732: Input Features: Dataset 'Z:\DATA FOR 2009\Base.gdb\CREEKS_UTM' does not exist or is not supported
I set a print message to print out the parameters for me and this is what i got:
Y:\2012_data\INFRASTRUCTURE.gdb\Buildings;'Z:\DATA FOR 2009\Base.gdb\CREEKS_UTM';'Z:\DATA FOR 2009\Base.gdb\LAKES_UTM'
The only anomaly I see is that the 2 feature classes from the Z:drive is being wrapped in single quotes when it returns the value, but the Y:drive doesn't. I have no idea why this is, but I'm thinking that is the issue I am having.
My script basically just reads in the parameters and clips to the extent of a raster file I have. The reason for the conditional statement in the loop is because the user may use a layer file from ArcMap or they may navigate to a feature class/shapefile and use that as an input. If they are using the layer in the map, then it reads it in as just the layer name (i.e 'Buildings'). If they navigate, then the parameter reads the whole file path and name (i.e Y:\2012_data\INFRASTRUCTURE.gdb\Buildings), so I need to parse it to use the base file name for the output parameter in the clip tool.
The files from the Z:drive is not being satisfied in the if/else statement. When I test against
os.path.isabs it ops to the
else part of the statement, so it must be having issues with the quotes in the
Any suggestions are welcome.
My script is as follows:
import arcpy, os inLines = arcpy.GetParameterAsText(0) inRaster = arcpy.GetParameterAsText(1) outRaster = arcpy.GetParameterAsText(2) pnt_array = arcpy.Array() extent = arcpy.Raster(inRaster).extent pnt_array.add(extent.lowerLeft) pnt_array.add(extent.lowerRight) pnt_array.add(extent.upperRight) pnt_array.add(extent.upperLeft) poly = arcpy.Polygon(pnt_array) for shp in inLines.split(';'): arcpy.AddMessage(shp) arcpy.AddMessage(os.path.isabs(shp)) if os.path.isabs(shp) == True: arcpy.AddMessage('if') (filename, ext) = os.path.splitext(os.path.basename(shp)) arcpy.Clip_analysis(shp, poly, outRaster + "\\" + str(filename) + "_Clip") else: arcpy.AddMessage('else') arcpy.Clip_analysis(shp, poly, outRaster + "\\" + str(shp) + "_Clip")