I have a large land cover map in a geodatabase, that I want to batch clip by defined catchments (about 63 polygons). The output files are named based on a field in the "clipper" (sys.argv[2]) called Watershed (currently a hard coded portion of my script).
The script below works if I run it on a shapefile, and point the outputs to an empty folder.
Ideally, I want to run this on a feature class, and point the outputs to a geodatabase using ArcMap9.3, however, I get the following error code: 000210: Cannot create output .
Does anyone have any suggestions? I have full permissions on my machine, and path directories are correct, so I'm not sure why I'm getting this particular error.
# Parameter list for ArcToolbox
# Parameter Properties
# Display Name Data type Type Direction MultiValue
# argv[1] Output workspace Workspace Required Input No
# argv[2] Layer used to Clip Feature Class Required Input No
# argv[3] Layer to be clipped Feature Class Required Input No
# argv[4] prefix for file name String Required Input No
#-----------------------------------------------------------------------------
#Import system modules
import sys
import string
import os
import arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")
# Designate a workspace for cliped vector data
gp.workspace = sys.argv[1]
# Assign variables to be processed...
clipper = sys.argv[2] # feature used to clip vector data
vector = sys.argv[3] # vector data to be clipped and then rasterized
suffix = sys.argv[4] # file naming convention prefix
# Search cursor sequence...
rows = gp.SearchCursor(clipper)
row = rows.Next()
feat = row.Shape # used as the clip_features in the Clip_analysis (clipper input must have a field called "Index_Key", which is used as the file name of each output)
while row:
n = str(row.Watershed) # assign a variable for the processing message based on a field
print "clipping to: " +n # tells you what grid was clipped
# Clip_analysis <in_features> <clip_features> <out_feature_class> {cluster_tolerance}
gp.Clip_analysis(vector, feat, str(row.Watershed)+"_"+str(suffix)+".shp", "") #update str if necessary
row=rows.next()
# reset the array...
del rows
del gp