I have a nationwide shapefile I want clipped into regions. There's not so many regions that I need to script iterating through each region, but there are enough where I want to batch process this. I explored using the Python interpreter built into ArcMap 10.5.1 to do so.
First I tested the process with one region and the following code works:
arcpy.Clip_analysis(in_features="WBDHU12", clip_features="07", out_feature_class="F:/GIS/07_HUC12s.shp", cluster_tolerance="")
Then, following instructions on entering multiple commands using the ArcMap Python window, I tried to do two clips for two different regions with one script execution:
arcpy.Clip_analysis(in_features="WBDHU12", clip_features="08", out_feature_class="F:/GIS/08_HUC12s.shp", cluster_tolerance="") ... arcpy.Clip_analysis(in_features="WBDHU12", clip_features="09", out_feature_class="F:/GIS/09_HUC12s.shp", cluster_tolerance="") ...
I'd expect that just as I could clip HUC12s to region 7 using that code successfully, I could clip HUC12s to region 8, and then again to region 9 one after the other. If this worked, I'd just setup the script to run all regions of interest and then let it geoprocess them all at once ('set it and forget it', I hoped). However, I hit this error:
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\analysis.py", line 62, in Clip raise e ExecuteError: ERROR 000725: Output Feature Class: Dataset F:\GIS\08_HUC12s.shp already exists.
I've tried a few different regions like this and anytime I run one region at a time, it takes a couple of minutes then completes the clip, but if I run two regions at a time, it instantly gives me this error and oddly enough it also instantly successfully clips the first region (e.g. in the example above, I'll have a new file in my catalog and map for HUC12s clipped to region 8). What I don't understand is:
Why is the clipping so fast when trying to do 2 regions in one script execution, whereas when doing 1 region per execution it takes longer?
Why am I getting an error about the out_feature_class already existing when I have set different out_feature_classes for each region / instance of clipping?