I'm having trouble creating a looping function that looks through a geodatabase, clips each feature class to a "study_area" polygon, and puts the clipped files in a separate geodatabase. I keep getting "Could not clip feature classes". The features can all be clipped individually but trying to run this loop doesn't work.
What am I missing here?
I tried to search for similar questions but only found answers regarding raster clips. Code below.
from arcpy import env # setting my source and target geodatabase SourceWorkspace = r"E:\UFD Commercial Corridor\Roosevelt.gdb" TargetWorkspace = r"E:\UFD Commercial Corridor\Clipped.gdb" #setting my clip feature (which is a polygon) clipfeature = r"E:\UFD Commercial Corridor\Clip area.gdb\study_area" env.workspace = SourceWorkspace try: fclist = arcpy.ListFeatureClasses() for fc in fcList: outClipFeatureClass = targetWorkspace + "//Studyarea_" + fc arcpy.Clip_analysis(fc,clipfeature,outClipFeatureClass) except: arcpy.AddError("Could not clip feature classes") print ("could not clip feature classes") print arcpy.GetMessages()