In this article, you’ll learn how to generate sequential and random numbers using the “field calculator” in ArcGIS Pro.
We are going to use both Python and Arcade to generate these values. But you don’t need to know how to code to get started.
Before we begin, check out this video that shows you step-by-step instructions on how to make use of sequential and random numbers in ArcGIS Pro.
Generating Sequential Numbers
Before you begin, you’ll need a field to store the sequential numbers and it should be preferably a long integer type.
Right-click the field that you want to generate sequential numbers and click “Calculate Field”.
One of the handiest things about ArcGIS Pro is that it has “Helpers”, which will write the code for you.
READ MORE: 20 ArcGIS Pro Tips and Tricks
If you scroll close to the bottom of the “Helpers” list, you’ll find “Sequential Number”. All you have to do is double-click this helper and it will populate it for you in the code block.
Here’s the code block:
# Type in as your field input SequentialNumber() # Calculates a sequential number rec=0 def SequentialNumber(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec = rec + pInterval return rec
Generating Random Numbers
Generating random numbers is just as simple as building sequential numbers. You’ll also need a long integer field, preferably, to store the values.
First, right-click your field and select “Calculate Field”. But this time instead of using “Python”, you can try out “Arcade” as it’s a bit easier.
In the “Helpers” section, find “Random” and double-click it. After the code block, type in an asterisk followed by the range that you want to use.
Here’s an example of a code block that will generate random numbers all the way to 100.