I am using ArcMap 10.3.
Is there a way to calculate a sorted field with sequential numbers in the Field Calculator or using an Update Cursor in ArcPy?
I have seen Sorting feature class to calculate sequential ID field using ArcGIS Field Calculator? that outlines how to calculate sequential numbers, but this is always calculated on FID order, not on sorted order.
#Pre-logic Script Code:rec=0def autoIncrement(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec += pInterval return rec#Expression:autoIncrement()
An example of what I'm trying to do. I've used an advanced sort to sort by year, month, day, and now want to have sequential numbers in the Seq
field. You'll see that my OBJECTID
field is not in order, so the above code won't work.