Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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 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)
share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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