Knowledge Base - Technical Articles
HowTo: Create sequential numbers in a field using Python in the Field Calculator
|Software:||ArcGIS - ArcEditor 10 ArcGIS - ArcInfo 10 ArcGIS - ArcView 10|
Instructions provided describe how to create sequential numbers in a field using Python in the Field Calculator.
The code in this article generates sequential numbers for unsorted data based on the OID or FID order. If your data is sorted on a field, the generated numbers will not be sequential.
- Create a new short integer field.
- Set the Parser to Python.
- Select Show Codeblock.
- Paste the following into the Pre-Logic Script Code:
pStart = 1
pInterval = 1
if (rec == 0):
rec = pStart
rec += pInterval
- Paste the following code in the smaller box below the Pre-Logic Script Code:
- Click OK.
- Create a sequential unique ID field equivalent to the ArcView 3.x field calculator expression rec+1
In ArcView 3.x, typing 'rec+1' in the field calculator creates a sequential unique ID field for a layer. Instructions provided describe how to do the equivalent in the ArcMap field calculator.
Last Modified: 12/17/2012
Article Rating: (14)