HOW TO

Automatically calculate polygon feature centroids using attribute rules in ArcGIS Pro

Last Published: March 14, 2025

Summary

In ArcGIS Pro, it is possible to automatically calculate polygon feature centroids and the coordinates when the polygon features are added or updated on the map. This functionality can be automated using attribute rules to ensure the centroids of the polygon features are consistently and accurately maintained, reducing manual calculations and minimizing the risk of errors.

This article provides the workflow to automatically calculate the centroids of polygon features using attribute rules.

Procedure

Note:
An ArcGIS Pro Standard license or higher is required to create and manage attribute rules.
  1. Open the project in ArcGIS Pro.
Note:
The feature layer requires Global IDs to add an attribute rule.
  1. Add a Global ID field to the attribute table of the polygon feature layer using the Add Global IDs tool.
  2. Create two new fields with the double data type to store the centroid X and Y coordinates. Refer to ArcGIS Pro: Create a field and apply a domain and default value for instructions. In this example, the X coordinate field is named Centroid_X, and the Y coordinate field is named Centroid_Y.
  3. In the Contents pane, right-click the polygon feature layer and click Data Design > Attribute Rules.
  4. In the Attribute Rules view, add attribute rules to the X and Y coordinate fields.
    1. On the Calculation tab, click the Add Rule drop-down menu and select Immediate Calculation.
    2. In the New Rule pane, specify a name for Rule Name. In this example, the rule is named 'Calculate the centroid X coordinate'.
    3. For Field, select the X coordinate field from the drop-down menu. In this example, Centroid_X is selected.
    4. In the Expression box, specify the following Arcade expression:
Centroid($feature).x
  1. Under Triggers, check the Insert and Update check boxes.
The attribute rules configurations pane
  1. Repeat Steps 5(a) through 5(e) to add a new rule for the Y coordinate field in the Attribute Rule view using the following Arcade expression:
Centroid($feature).y
  1. On the Attribute Rules tab, in the Manage Edits group, click Save.

The following image shows the X and Y coordinates of the centroids are automatically calculated when new polygon features are added to the map.

The centroids automatically calculated after adding new polygon features to the map

Article ID: 000035103

Software:
  • ArcGIS Pro 3 3
  • ArcGIS Pro 3 2
  • ArcGIS Pro 3 4

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options