Cut/extract multiple feature classes at once

937
2
01-24-2019 11:01 AM
by Anonymous User
Not applicable

I have 30+ feature classes in a FGDB. I need to extract them to shapefiles cut down to the size of my project boundary - in a State Plane projection. 

Is there a tool to do them all at once instead of manually using the Select by Location tool and extracting one-by-one?

0 Kudos
2 Replies
StephenM
Occasional Contributor II

One option might be to use batch clip and batch project.

A quick tour of batch processing—Help | ArcGIS Desktop

Another option would be to do this using a few tools in ArcPy: ListFeatureClasses to list the feature classes in a workspace, Clip to clip the feature classes to the project boundary, and Project and SpatialReference to reproject them.

A quick example:

ws = "C:\\Users\\username\\Desktop\\temp.gdb"
arcpy.env.workspace = ws
fcs = arcpy.ListFeatureClasses()
output = "C:\\Users\\username\\Desktop\\temp\\"
out_cs = arcpy.SpatialReference(####)
i = 1
for fc in fcs:
    arcpy.Clip_analysis(fc,"clipper",output+"temp"+str(i)+".shp")
    arcpy.Project_management(output+"temp"+str(i)+".shp",output+"temp"+str(i)+"_sp.shp",out_cs)
    i += 1‍‍‍‍‍‍‍‍‍‍

In this example, some feature classes are located in a geodatabase (temp.gdb), one of which is the target shape ("clipper"). Each feature class in the geodatabase is clipped to the "clipper" shape and output as a shapefile to a folder named "temp". The shapefiles are named "temp_#.shp", where the number is incremented on each iteration of the "for" loop. After clipping, the shapefiles are projected to another coordinate system—which is selected using arcpy.SpatialReference—and "_sp" is appended to the projected shapefile name.

0 Kudos
by Anonymous User
Not applicable

I found the batch processing option in the past...which would be perfect if I worked for a County and all my feature classes stayed the same name...but to set this up for every county my internal clients work in...each using a different naming structure, it would take the same amount of time to do it manually as to set up the Batch Processing.

I am interested in your second option tho...that sounds promising and something I've not tried yet. The numbering of the output files is a bit troubling - it's hard to differentiate valves and pipes on different utility systems without taking a closer look...and then renaming all of the shapefiles so my CAD users know what they are.  This would add possible errors into the mix, but it sounds better than the manual option.  It also leads me to a traditional model option which could work.  Thank you for your suggestions!

0 Kudos