3

I have 100 different input vector layers and one clip feature vector layer.

I have to clip them 100 times but its a large amount of work.

Is there any Python script (ArcPy) in ArcGIS for Desktop to accelerate my work and avoid the one by one clipping?

7

You can use a simple block of code either directly from Python window in ArcGIS or as a Python script or as a custom script tool.

Below is a sample code for a script tool. Just add your vector layers into a map document (.mxd) and specify the clip layer and the output geodatabase.

import os, arcpy
arcpy.env.overwriteOutput = True

clip_layer = arcpy.GetParameterAsText(0)
out_gdb = arcpy.GetParameterAsText(1)

mxd_obj = arcpy.mapping.MapDocument("CURRENT")

for lyr in arcpy.mapping.ListLayers(mxd_obj):
    arcpy.AddMessage(lyr)
    out_layer = os.path.join(out_gdb,lyr.name)
    arcpy.Clip_analysis(lyr,clip_layer,out_layer)
6

In you case (only one tool), you can simply right click on the clip tool in your toolbox, and launch it as a "batch". See the ArcGIS help for more details

5

You can place all the feature classes within a single dataset then use model builder to clip all at once and output to a new dataset: enter image description here enter image description here

  • The images are nice for instant recognition, "yes, I'm in the right place". The parameters would benefit from being reiterated in the answer body as text; they're almost too small to read. – matt wilkie Jan 29 '15 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.