Automating Sorted Number Generation For Large Arcgis Datasets

The Problem of Manual Numbering in ArcGIS

Performing manual numbering of features in ArcGIS can be an extremely tedious and time-consuming process. For large datasets with hundreds of thousands or millions of features to number, the task of manually assigning numbers to each feature ID can be highly prone to human error and lacks efficiency. Automating the numbering process is critical for improving workflows for large geospatial data projects.

A common example can be found when numbering utility pole assets for electric utilities. With some utilities managing over 5 million poles across large regions, manually assigning each pole a unique identifier could take a single GIS analyst months or years to complete. Rather than waste such extensive resources, a scripted approach is needed.

Other instances that require numbering extremely large collections of point, line, or polygon features include address points, utility valves, cellular towers, sampling locations, and more. Manually handling the numbering in these cases may start feasible but quickly grows unruly.

By leveraging the Python scripting integration available within ArcGIS Pro and ArcGIS Desktop, we can automate the numbering process by programmatically generating sorted numerical identifiers for features based on total count or other attributes. This eliminates the need for tedious manual work and reduces chances for duplication or omitted values.

Generating Sequential Numbers in Python

The first step in automating number generation for ArcGIS data is accessing the total count of features that require numbering in the active data frame session. We can obtain this value using the arcpy library’s GetCount_management function to return an integer count.

Next we construct a For loop in Python that iterates over the range from 1 to the total feature count. By iterating we can assign numerical values to a variable that serves as our ID. Formatting the ID value as a string with leading zeros pads the numbers with 0’s to maintain a fixed length.

For example, with 156,412 features we would iterate from 1 to 156412. Each ID value is formatted as a string to appear as 000001, 000002, 000003, and so on. This formats the numbers in a clean fashion despite varying lengths.

Applying Automated Numbering in ArcGIS ModelBuilder

To integrate the automated numbering script into our ArcGIS workflow, we can build a script tool and incorporate it into a ModelBuilder model. This allows us to connect our feature class needing numbering as input data, execute the Python script on that data, and workflow the outputs back into ArcGIS for analysis or mapping.

After constructing a script tool wrapper around our numbering script, we open ModelBuilder and drag the script tool into the model canvas. We add our feature class dataset for numbering by connecting it to the script tool’s input parameter. Configuring the data type and other parameters controls the flow into the numbering script when executed.

On the outbound side from the script tool, we add tooling such as Calculate Field or UpdateCursor to bind the generated ID values from the Python iterator to the desired attribute field or ObjectID. This completes the flow from input data, through numbering script, and back out to ArcGIS with the field populated number values.

Example Workflow Walkthrough

To illustrate the implementation of this automated numbering process, we will walk through an example using polygon land parcel data containing over 150,000 features needing unique ID values.

First, inspecting the layer properties shows 156,412 total features in the parcel polygon class that need numbering. Next we right click on the layer and select Properties > Definition Query tab > Query Builder. Here we add an order by clause on a field we want to sort the numbering sequence by, such as an existing site number field to keep sites with similar numbers sequentially located.

Then in our Python IDE (ex: IDLE) we construct our iterator to generate the sequential numbers from 1 to 156412, padding each number to a total width of 6 ordered characters. This script is saved as a script tool into a ArcGIS Pro project for model integration.

We open ModelBuilder and drag our parcel polygon layer in as input data and connect it to the script tool. On the outbound side we calculate a new field binding the generated ID numbers to the feature attribute table via arcpy cursors. After saving and executing we now have automated numbered IDs populated sequentially based on the defined sort order.

Conclusion

By leveraging Python scripting tools available within ArcGIS, automating the numbering and ID generation for large feature class datasets provides immense efficiency gains over tedious and duplication-prone manual handling. Sorting algorithms can also be introduced to sequentially locate logically grouped features.

The model builder integration gives users a seamless workflow to introduce automation into spatial data workflows without needing to work externally from the ArcGIS environment. This allows even GIS analysts with limited programming experience to reap the benefits. Use cases are abundant for nearly any project requiring unique ID values generated for thousands to millions of features.

Leave a Reply

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