I am a Python newbie, so forgive me if this question is pretty simple.
I'm trying to iterate through a shapefile feature class. The shapefile contains a bunch of points that I'm trying to clip based on another layer. This is what the script looks like when I do it:
arcpy.Clip_analysis('RF_Acreage', 'Lake_Ontario_Plains_FDRA_Boundary', r'L:\OPP\Rangers\Central Office\GIS\Deidre GIS Reporting Files\testmodel\Modeloutputs.zxgdb')
It works fine on it's own, but I need to do it for multiple regions. so it would be very tedious to clip one by one. So basically my input features will stay as 'RF_Acreage' while I clip it too different features.
Should I be using if statements and for loops? If so, how do I go about stringing these together?
Hopefully I'm making sense. Thanks in advance!
Also make sure you are naming out of your output features a unique name, otherwise it will either crash or overwrite the features you are creating.
If you have a relatively small number of features, it might be easier to run clip in batch mode rather than write out a script. As long as you set parameters that stay the same before you add new rows in batch, it will keep the parameters the same for each row.
But I only have 1 feature class I'm working with. I'm trying to clip it into multiple feature classes. Sorry if I wasn't clear. Do I create a list of the one feature class and to a for loop to clip it to different layers?
You would make a list of the feature class you want to clip with and leave the input the same for the 1 feature class you want clipped. You would then loop through each of the feature classes you want to clip with and use each individual one as the clipping layer for the tool. Your input would stay the same each time.
With the suggestions posted so far and the example posted in the Clip Analysis Help, you should be able to get started. Here's what the list and the for loop might look like...
clip_features = [ 'Lake_Ontario_Plains_FDRA_Boundary', 'Another_FDRA_Boundary', 'Some_FDRA_Boundary', 'Other_FDRA_Boundary' ] for fc in clip_features: out_feature_class = in_features+fc ## Naming is up to you arcpy.Clip_analysis(in_features, fc, out_feature_class)