aorr

Extract each feature of a feature class script

Discussion created by aorr on Apr 27, 2012
Latest reply on Apr 30, 2012 by mzcoyle
Hi,
This is a very simple operation, but somehow I cannot figure out how to do it, nor can the people I've asked in person.
I have a feature class. I want to use a search cursor to iterate down each row (feature) and save it as its own feature class.

I've tried doing this with making Feature Layers and selecting a single record with a for loop, but that doesn't seem to work. This is what I've done so far:

arcpy.MakeFeatureLayer_management(COUNTIES,"counties_lyr")
arcpy.MakeFeatureLayer_management(HUC, "huc_lyr")

rows = arcpy.SearchCursor(HUC, "", "", "", "")
for row in rows:
    arcpy.SelectLayerByAttribute_management("huc_lyr", "NEW_SELECTION", "")
    arcpy.CopyFeatures_management("huc_lyr", "test" + str(row.FID_HUC8_U))


The feature class that is returned contains all of the features from the original. In other words, it's exactly the same feature class.

Thanks for the help,
-Andy

Outcomes