I have a gdb
of point features. I want to iterate through the gdb, select the point features that are within a polygon shapefile, and export the selected feature results to a new gdb. However, I only want to retain geometry
and uniqueid
fields for the new selected features that I want to output to my new gdb.
# Import system modules
import arcpy
import os
# Set environment settings
arcpy.env.workspace = "C:/data/input.gdb"
# Set local variables
out_workspace = "c:/output/output.gdb"
# Boundary polygons for select by location
boundaries = "C:/data/boundaries.shp"
# Use ListFeatureClasses to generate a list of shapefiles in the workspace
fc_list = arcpy.ListFeatureClasses()
# Execute CopyFeatures for each input shapefile
for feature in fc_list:
out_featureclass = os.path.join(out_workspace, feature + "_withinbounds")
### HERE IS WHERE I NEED TO FILTER ATTRIBUTES
within_features = arcpy.SelectLayerByLocation_management(feature, "WITHIN", boundaries, "", "NEW_SELECTION")
arcpy.CopyFeatures_management(within_features, out_featureclass)
Where would I put this code and how would I filter and retain just those attributes before exporting the new features using CopyFeatures_management
?