Hi,
How can I iterate through feature layer or feature class by arcpy.da.SerachCursor and arcpy.da.UpdateCursor within a certain geographic extent? Right now I am making feature class copying the content. Is this most efficient method? Basically I have giant feature class, and I want to visit geographic subdivision of the feature class and then do my processing there.
# I have a feature class. I made it into feature layer
arcpy.MakeFeatureLayer_management(poly_fc, tmp_lyr)
# I then set extent to the part of data that I want to process
arcpy.env.extent = extent1
# if I count the feature from the layer, I got the count of feature in the extent.
# if I copy it into feature class I got the featueres inside the extent
n0 = int( arcpy.GetCount_management(tmp_lyr).getOutput(0)) # I got corrent n0
arcpy.CopyFeatures_management(tmp_lyr, selected_fc) # I got fc of only the feature within extent1
# But iterating the tmp_lyr visits all featuers in tmp_lyr, ignoring the arcpy.env.extent
lst = [ _[0] for _ in arcpy.da.SearchCursor(tmp_lyr, ['SHAPE@'])]
# lst above contains all features, not just the one in extent
# if I access through the copied fc, I get what I want, i.e., features within the extent
lst_small = [ _[0] for _ in arcpy.da.SearchCursor(selected_fc, ['SHAPE@'])]
# lst_small above contains what I want
# so I just process on the copy....
with arcpy.da.SearchCursor(selected_fc, ['SHAPE@']) as cur:
for row in cur:
# my processing here...
pass