import arcgisscripting, sys, os gp = arcgisscripting.create() gp.workspace = "D:\inWorkspace" clipFeatures = "D:\shape.shp" outWorkspace = "D:\outWorkspace" fcs = gp.ListFeatureClasses() fcs.Reset() fc = fcs.Next() while fc: outFeatureClass = outWorkspace + os.sep + fc.split('_')[0] + "_clip.shp" gp.Clip_analysis(fc, clipFeatures, outFeatureClass, "") fc = fcs.Next()
import arcgisscripting, os gp = arcgisscripting.create() clippers = "c:/junk/clippers/" toBeClipped = "c:/junk/toBeClipped/" output = "c:/junk/toBeClipped/output/" # Get a list of the "clippers" for fc in os.listdir(clippers): if fc.endswith('.shp'): # Get a list of the files to be clipped. for shp in os.listdir(toBeClipped): if shp.endswith('.shp'): print "Clipping "+shp+" with "+fc # NOTE: add the name of the "clipper" onto the output name so it's unique. gp.Clip_analysis(toBeClipped+shp, clippers+fc, output+shp[:-4]+fc)
gp.extent = "MAXOF"in the script to see if it works.
I get the "Extent of the overlay operation will be empty. " error.
import arcgisscripting, os gp = arcgisscripting.create() clippers = "c:/junk/clippers/" toBeClipped = "c:/junk/toBeClipped/" output = "c:/junk/toBeClipped/output/" # Get a list of the "clippers" for fc in os.listdir(clippers): if fc.endswith('.shp'): # Get a list of the files to be clipped. for shp in os.listdir(toBeClipped): if shp.endswith('.shp'): print "Clipping "+shp+" with "+fc # NOTE: add the name of the "clipper" onto the output name so it's unique. try: gp.Clip_analysis(toBeClipped+shp, clippers+fc, output+shp[:-4]+fc) except: print "ERROR output emtpy: "+output print "\nDone.\n"
I have a single shapefile that I need to clip multiple times with different shapefiles. It seems like the code in this thread should work, but I tried the script and did not get any results. No error messages, just nothing in the output folder. How should I change the script to work with version 10 and my current workflow?