HOW TO

Label a feature layer using the unique end characters of the field value in ArcGIS Pro

Last Published: March 8, 2022

Summary

In ArcGIS Pro, when labeling a feature layer using a field containing repeating values with unique end characters, it is sometimes necessary to omit the repeating values and display only the unique end characters to avoid confusion and improve the readability of the labels.

For example, the image below displays labels for the Locality feature layer containing repeating values with two unique end characters. The following workflow describes how to label the feature layer using the last two unique characters of the field value.

In ArcGIS Pro, the labels for the Locality feature layer displayed repeating values with two unique end characters.

Procedure

  1. Launch ArcGIS Pro and open the project.
  2. In the Contents pane, browse to and click the feature layer.
  3. On the top ribbon, click the Labeling tab on the Feature Layer contextual tab.
  4. In the Layer group, click Label The Label icon provides the function to enable or disable labeling on a layer. to enable labeling on the layer.
  5. In the Label Class group, click the Field drop-down arrow, and select the field for labeling. Click the Expression icon to display the Label Class - <layer_name> pane.

In the Label Class group, the Expression icon displayed besides the Field drop-down arrow.

  1. In the Label Class - <layer_name> pane, on the Label expression tab, click the Language drop-down arrow and select Python. Check the Advanced check box.

On the Label expression tab, select Python as the expression language, and check the Advanced check box located below Function.

  1. In the Expression text box, type the following expression to remove the repeating part of the value from the field, and click Verify The Verify icon.. In this example, the first 29 characters are removed from the field value.
def FindLabel (<field_name>):
    s = <field_name>
    return s[<number_of_characters_to_be_removed>:]

The expression to remove part of the values from the field is displayed in the Expression text box.

  1. When the message, ‘Expression is valid’ is returned, click Apply.

The image below shows the labels display the two unique end characters of the field values in ArcGIS Pro.

In ArcGIS Pro, the labels for the Locality feature layer displayed the two unique end characters in ArcGIS Pro.

Article ID: 000027242

Software:
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 7 x
  • ArcGIS Pro 2 x

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