batch clip one feature using multiple clip extents

403
4
05-01-2012 08:25 AM
AnnKitowski
New Contributor III
I have a soils feature class that I want to clip.  I have a township feature class that I want to use as the clipping extent.  However, I want to clip soils by each township in order to find the acreage of a certain soil in each town.  Right now in ArcMap I'd have to select one township, clip out the soils, get an output.  But I have to do that 22 times.  Not a huge deal if it's a one time thing, but I need to use this functionality over and over for other stuff, so it would be nice to somehow batch clip.  There are so many posts on how to clip multiple feature classes using the same clip extent but not the other way around.  Anyone know how to do this?
0 Kudos
4 Replies
MathewCoyle
Frequent Contributor
You'll want to use python for this (or model builder if you are so inclined). For this example I assume each township extent is it's own feature class in a directory. It appends a unique count number to the end of the output if they don't have unique names. This should give you a good place to start.

import arcpy
import os
ws = r"C:\your_township_dir"
arcpy.env.workspace = ws
outdir = r"C:\outdir"
soils_fc = "path_to_soils_fc"
soils_temp = r"in_memory\soils_temp"
arcpy.MakeFeatureLayer_management(soils_fc,soils_temp)
twp_temp = r"in_memory\twp_temp"
fc_list = arcpy.ListFeatureClasses()
unique = 1
for fc in fc_list:
    arcpy.MakeFeatureLayer_management(fc,twp_temp)
    arcpy.Clip_analysis(soils_temp,twp_temp,os.path.join(outdir,fc+unique))
    unique += 1
    
0 Kudos
AnnKitowski
New Contributor III
Thanks for the script.  The townships are all in one feature class.  Can a script go through the clipping process and pick a different town by name each time? Is it also possible to have just one output feature class?
0 Kudos
MathewCoyle
Frequent Contributor
That sounds more like an intersect operation than a clip.
0 Kudos
AnnKitowski
New Contributor III
Ah ha!  That did exactly what I wanted.  Thanks so much Mathew!!!  Boy, do I feel dumb.
0 Kudos