AnsweredAssumed Answered

Weird File Path Returning from Print Statement Causing ERROR 000732

Question asked by BrokenLegMike on Apr 8, 2013
Latest reply on Apr 8, 2013 by BrokenLegMike
0 down vote favorite

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. If they navigate, then the parameter reads the whole file path and name, so I need to parse it to use the base file name for the output parameter in the clip tool.

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