AnsweredAssumed Answered

clip from multiple folders and gdb

Question asked by peterverst on Jan 21, 2015
Latest reply on Jan 22, 2015 by peterverst


With lots of help I have a script that search my folder and gdb for featureclasses and rename them. That script works great.


The next step in my workflow will by clipping. I want the clip feature to clip all my featuresclasses in all folders and gdb’s. I am using the rename script as kind of a template.


The problem now is in a unique output name (the name of the featuresclasses in the gdb are the same (not the factor only the name).


The script I have so far is wrong but it I was hoping it could do the trick if I set it right.

So far the error is in line 10 the join is not working I do not know if the unique_name will work but that is my solution for the unique name problem.


BTW I was think about a script that looks at the extend (clip feature) first and if true then clip and if not nothing.  I am over my head already and I have a script that cleans my gdb’s of empty featureclasses. So for now for my this is ok.


import os 
import arcpy  
from arcpy import env

workspace = "D:\\GIS\\Zone1\\Zone1A"  
feature_classes = []
clipfeature = "D:\\GIS\\Temp\\clip.gdb\\BorderClip"
outputdatabase = "D:\\GIS\\Output\\clip.gdb"
walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="All")  
fc_output = os.path.join(outputdatabase,filenames)
unique_name = arcpy.CreateUniqueName(fc_output)

for dirpath, dirnames, filenames in walk:  
    for filename in filenames:  
        feature_classes.append(os.path.join(dirpath, filename))  
#    arcpy.AddMessage("clipping: " + feature_classes)
arcpy.Clip_analysis(feature_classes, clipfeature, ounique_name)


Greeting Peter