I'm trying to iterate through a feature class and select each feature one by one by using the OBJECTID field. When I use a single value, the SelectLayerByAttribute works, but how do I compare the OBJEECTID to a variable that increases in count through the loop. The program is then suppose to create a layer for each feature in the feature class. This is what I have so far:
import arcpy
import os
arcpy.env.workspace = "C:\Users\Daimon Nurse\Desktop\DFMPROJECT\DFMPROJECT.gdb"
arcpy.env.overwriteOutput=True
inlayer = "C:\Users\Daimon Nurse\Desktop\DFMPROJECT\DFMPROJECT.gdb\ZonesPolyline"
with arcpy.da.SearchCursor(inlayer, ("OID@", "SHAPE@AREA")) as cursor:
i = 1
for row in cursor:
print("Feature {0} has an area of {1}".format(row[0], row[1]))
outlayer = "ZonePolygon"
arcpy.MakeFeatureLayer_management (inlayer, outlayer)
arcpy.SelectLayerByAttribute_management (outlayer, "NEW_SELECTION", """ "OBJECTID" = 1 """)
output = r'C:\Users\Daimon Nurse\Desktop\Grounds Project\DFMGROUNDS.gdb'
outfile = os.path.join (output, i)
arcpy.CopyFeatures_management(outlayer, outfile)
print i
i = i + 1