Summary
In ArcGIS Pro, sometimes it is necessary to display numeric field values with leading zeroes when displaying as labels for better data management. The leading zeroes can be added to the numeric field values in the attribute table in ArcGIS Pro. However, this article provides the workflow to add leading zeros when displaying labels using a Python or Arcade expression while retaining the original data in the attribute table in ArcGIS Pro.
Procedure
- Open the ArcGIS Pro project, add the layer, and create the label expression. For instructions, refer to Steps 1 through 4 in ArcGIS Pro: Write a label expression, and select Arcade or Python from the Language drop-down list.
Note:
In the Contents pane, ensure the feature layer and feature class check boxes are checked to display the labels.
- In the Label Class pane, configure the following parameters in the Expression box:
- For Arcade, replace <field_name> with the name of the field to be displayed as labels. Replace <value> with the number of zeroes according to the number of digits. In this example, the expression is used to add leading zeroes to make five digits.
Text($feature["<field_name>"], '<value>')
- For Python, replace <field_name> with the name of the field to be displayed as labels. Replace <value> with the number of zeroes according to the number of digits. In this example, the expression is used to add leading zeroes to make five digits.
[field_name].zfill(<value>)
- Click Verify to validate the expression.
- Click Apply to run the script.
The map below displays the data with leading zeroes in the labels.