Home » GIS Analysis » Sequential and Random Numbers in ArcGIS Pro

Sequential and Random Numbers in ArcGIS Pro

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.

Random()*100

Conclusion

In this article, we explained how to generate sequential and random numbers using ArcGIS Pro.

If you’re looking to learn Python or Arcade, here are some more helpful articles to set you on the right path:

Subscribe to our newsletter:

7 Comments

  1. Ok, problem was I didn’t select Helper Filter type of Function. Once I did that the Sequential help showed up. It didn’t before even with filter set to all. You have to select Function as the filter type (at least in my version 3.1.2)

    1. I am using ArcGIS Pro 3.1.1. Just to recap the steps:

      Step 1) Open the attribute table.
      Step 2) Right-click your numeric field and click “Calculate Field”.
      Step 3) There’s a filter button in the top-right. Make sure this “All” is selected.
      Step 4) Double-clicking the “helper” will populate the code block.

      Do you see any “helpers” at all? Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *