Summary
In ArcGIS Pro, numeric data in a feature layer, such as the crime ratio of cities, can be labeled or symbolized using a range of percentages. In this article, an Arcade expression is used to create labels or symbolize a feature layer with the desired range of percentages.
Procedure
Display the percentage range as labels
- Open the ArcGIS Pro project, add the layer, and create the label expression. For instructions, refer to Steps 1 through 4 in ArcGIS Pro: Writing a label expression, and select Arcade for Language.
Note:
Ensure the selected feature layer and feature class check boxes are checked in the Contents pane to display the labels.
- Insert and configure the expression below in the Expression box:
var <variable_name> = $feature.<field_name>
if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else {
return "<range of percentage>";
}
- Replace <field_name> with the name of the field to display the range of percentages as labels. In this example, ‘Ratio’ is the selected field.
- Replace <variable_name> with the desired variable name. In this example, ‘Ratio’ is the variable name.
- Replace <field_value> with the desired field’s values from the attribute table.
- Replace <range of percentages> with the desired text for the labels. In this example, the range for the percentages are used as the texts.
Note:
The number for the range of percentages can be specified as per the requirement of the field’s attribute value.
- Click the Verify button to validate the expression.
- Click Apply to run the script.
The image below displays the range of percentages for the field as labels on a map.
Display the range of percentages with the unique value symbology in a layout
- Open the ArcGIS Pro project.
- Symbolize the feature layer with the unique value symbology. For instructions, refer to Steps 1 through 2 in ArcGIS Pro: Unique values. In this example, ‘Ratio’ is the selected field.
- Click the expression button
to open the Expression Builder dialog box. - Insert and configure the expression below in the Expression box:
var <variable_name> = $feature.<field_name>
if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else if (<variable_name> <= <field_value>) {
return "<range of percentage>";
} else {
return "<range of percentage>";
}
- Replace <field_name> with the name of the field to display the range of percentages for the symbology. In this example, ‘Ratio’ is the selected field.
- Replace <variable_name> with the desired variable name. In this example, ‘Ratio’ is the variable name.
- Replace <field_value> with the desired field’s values from the attribute table.
- Replace <range of percentages> with the desired text for the legend.
Note:
The number for the range of percentages can be specified as per the requirement of the field’s attribute value.
- Click the Verify button to validate the expression.
- Click OK to run the script.
- Insert a layout and map frame for the map. Refer to ArcGIS Pro: Insert a layout and ArcGIS Pro: Insert a map frame for instructions.
- In the layout view, on the top ribbon, in the Map Surrounds group, click Legend and create a legend to display the range of percentages for the values of the field.
The image below displays the range of percentages for the field represented through the unique value symbology in a layout.