So I have multiple rivers within the one shapefile, I want to get the length for each river, I have this script inserted into the field calculator but it outputs a total for all the rivers, I would like to stop with every new river and start a new total.
Expression:
accumulate(!Shape_Length!)
Code Block:
total = 0
def accumulate(increment):
global total
if total:
total += increment
else: total = increment
return total
I have a river ID to differentiate each river in the shapefile. This can be seen in the image as SegmentID