I have a feature class Test_NearestNeighbor_Code
. This feature class has 7373 polygon features and a column/ field called osm_id
. I want to do a calculation with all features that have the same osm_id
. How can I do this in arcpy in an iterative way over all features (without using the ModelBuilder)?
Calculate Field code works, but loop with SearchCursor
doesn't, any suggestions for improvement?
Attached the Attribute Table of the feature class Test_NearestNeigbour_Code
.
with arcpy.da.SearchCursor("Test_NearestNeighbour_Code", ["osm_id"]) as cursor:
for row in cursor:
arcpy.management.CalculateField("Test_NearestNeighbour_Code", "Dispersitätsmaß", "nn_output[1]", "PYTHON3", 'nn_output = arcpy.stats.AverageNearestNeighbor("Test_NearestNeighbour_Code", "EUCLIDEAN_DISTANCE", "NO_REPORT", None)', "DOUBLE", "NO_ENFORCE_DOMAINS")```