Hi,
I have an attribute table with over 760,00 polylines (River Segments). I want to group these river segments into 380 individual features (Rivers). I need a python script / ModelBuilder method that can for loop over a attribute field, that every time the value reverts back to 0 it creates a feature or inputs an incremented value into another field (RiverID). This can be seen in the attached photos in the field "segmentInd'; as this field is the number of measurements from the river source in an ascending order downstream.
There are no other fields that are unique to allow me to select by them.
I am new to python and do not know how to for loop over an attribute table.
Solved! Go to Solution.
Copy/paste this script into the Python Window, change the name of the layer, execute
river_id = 0
with arcpy.da.UpdateCursor("NameOfTheLayer", ["segmentInd", "RiverID"]) as cursor:
for row in cursor:
if row[0] == 0:
river_id += 1
cursor.updateRow([row[0], river_id])
Copy/paste this script into the Python Window, change the name of the layer, execute
river_id = 0
with arcpy.da.UpdateCursor("NameOfTheLayer", ["segmentInd", "RiverID"]) as cursor:
for row in cursor:
if row[0] == 0:
river_id += 1
cursor.updateRow([row[0], river_id])
Johannes Thank you so much. This worked like a charm!