tut Pro Arcade Labels
Using Arcade for Custom Labels
(return to the ArcGIS PRO / Cartography Tutorials page)
See also Arcade for Custom Pop-Ups
Arcade is an Expression language developed by ESRI for use with ArcGIS Pro, ArcGIS Online and spatial data sets. Arcade includes a collection of 'functions' that can be used to modify values, including values from attribute fields.
In addition to symbology, pop-ups, etc. Arcade can be used for customizing Labels. (Note that all of the examples below use the Arcade expression language. ArcGIS Pro can also use VBscript, Javascript, or Python for similar functions, using different syntax).
Perhaps the most basic use of Arcade is to display labels based on the value of a field in the attribute table, in this case using the NAME field from a polygon layer of Washington State Counties using basic census data.
Numerical fields can also be used for labels - below is an example using a Square Miles (SQMI) field:
Changing Case
Arcade includes functions for changing the case (UPPER CASE vs lower case vs Proper Case) of a text string.
Below is an example using the upper( ) function to convert the text from the NAME field to upper case:
You can also use the lower( ) function or the proper( ) function.
Concatenating Text Strings
You can concatenate multiple fields using the + operator. You can also use the + operator to append a text string to a field value:
Use <field1> + " " + <field2> to insert a space between the values from two fields.
Insert a Carriage Return (Line Feed)
To insert a carriage return between two text strings use the + operator and the textFormatting.NewLine function:
Below is an example of inserting a carriage return and the 2000 Population (POP2000) field:
Formatting Numbers as Text
Numerical fields can be converted to text and then formatted (i.e., including commas or a specified number of decimal places) using the text( ) function:
Numbers can also be rounded off, averaged, etc.
Mathematical Calculations
Standard mathematical calculations can be performed on numerical fields. This can be used to add or multiple fields, to convert from Fahrenheit to Celsius or from Miles to Kilometers, etc.
Below is an example converting square miles (from the SQMI field) to acres:
And since the derived output (square miles * 640) is a number, we can format that as well:
In addition, we can concatenate additional fields and text strings and carriage returns...:
Geometry Functions
Arcade can also be used to obtain geometric information for a feature (i.e., information not contained in the attribute table).
For example, you can use the Area( ) function to obtain the area of a polygon (in the units you specify.
Or you can use the Centroid( ) function to return a point location for the centroid of a polygon.
And the Geometry( ) function can be used to obtain the X or Y coordinates of a point.
There are also functions to identify features based on proximity: Contains( ), Overlaps( ), etc.
More Examples
Below is a short list of some of the more commonly used Arcade functions:
Text (Case):
- Proper case proper($feature.FIELD)
- Lower case lower($feature.FIELD)
- Upper case upper($feature.FIELD)
Concatenation
- Add text $feature.FIELDname + “ some new text…”
Or “Some text and: “ + $feature.Field - Add a field $feature.FIELD1 + $feature.FIELD2
- Add a space $feature.FIELD1 + “ “ + $feature.FIELD2
- Add a new line $feature.FIELD1 + TextFormatting.NewLine + $feature.FIELD2
Numbers / Math
- Add a comma Text($feature.NumberFIELD, “#,###”)
- Add a constant $feature.NumberFIELD + 10
- Divide by a constant $feature. NumberFIELD / 10
- Add two fields $feature. NumberFIELD1 + $feature.NumberFIELD2
- Round off to integer round(number($feature.NumberFIELD), 0)
To 2 decimals round(number($feature.NumberFIELD), 2) - Currency “$" + round($feature.NumberFIELD, 2)
Or "$" + text($feature.NumberFIELD,"#,###.##")
Conditional
- If statement if ($feature.FIELD1 > 600) {return $feature.FIELD2}
Text Formatting
- Bold "<BOL>" + "Some Text" + "</BOL>"
Or "<BOL>" + $feature.FIELD + "</BOL>" + " Some Text" - Italic "<ITA>" + $feature.FIELD + "</ITA>" + " Some Text"
- Underline "<UND>" + $feature.FIELD + "</UND>" + " Some Text"
- Underline "Some Text”>" + “<SUP>” + $feature.FIELD + "</SUP>"
- Font Size "<FNT size= ‘8’>" + $feature.FIELD1 + "</FNT>" + $feature.FIELD2
- Font Name "<FNT name= ‘Arial’>" + $feature.FIELD1 + "</FNT>" + $feature.FIELD2
- Font Color "<CLR yellow= ‘100’>" + $feature.FIELD1 + "</CLR>" + $feature.FIELD2
- Background "<BGD yellow= ‘100’>" + $feature.FIELD1 + "</BGD>" + $feature.FIELD2
See also:
- https://developers.arcgis.com/arcade/function-reference/
- https://pro.arcgis.com/en/pro-app/latest/help/mapping/text/specify-text-for-labels.htm
- https://pro.arcgis.com/en/pro-app/latest/help/mapping/text/text-formatting-tags.htm