Académique Documents
Professionnel Documents
Culture Documents
ArcGIS 10.4
Locate topic
You can use label expressions to adjust the formatting of your labels. In addition to inserting
characters and scripting functions, you can use ArcGIS formatting tags in label expressions.
These are special characters for changing the appearance of all or part of your labels. For
example, you might use the bold formatting tag to make the first line bold in a stacked, multiline
label.
A label expression is limited to a single line of code unless you check the Advanced box on the
Label Expression dialog box. Checking the Advanced box allows you to enter a function
containing programming logic and spanning multiple lines of code.
Field values are automatically cast to text strings. Therefore, if you wish to use a numeric value
in an arithmetic operation, or when making a comparison, you will need to cast it back to a
numeric data type. The examples below add two integer fields:
Python
int([FIELD1]) + int([FIELD2])
VBScript
cint([FIELD1]) + cint([FIELD2])
JScript
parseInt([FIELD1]) + parseInt([FIELD2])
Steps:
5. Type a Python, VBScript, or JScript expression. You can also create an expression
by double-clicking the field to add it to the expression or by selecting the field
and clicking the Append button to append the field to the end of the expression
separated by a space.
Fields are enclosed in square brackets [ ] irrespective of the data type of the
layer's data source.
Optionally, enter ArcGIS text formatting tags in the Expression box to apply
formatting to a portion of your label text.
If your expression will span multiple lines of code, check the Advanced check box
and enter your label expression.
Tip:
Both regular and advanced label expressions can be saved as label expression files (.lxp), which
can be loaded into other layers or maps.
Expression examples
The following are examples of label expressions:
Concatenate a string to the value in a field. For example, this expression creates a label
where the value of the PARCELNO field is preceded by the text "Parcel no:":
Python
VBScript
JScript
Round a decimal number to a set number of decimals. For example, this expression
displays an Area field rounded to one decimal place:
Python
round(float([AREA]), 1)
VBScript
Round ([AREA], 1)
JScript
Convert your text labels to all uppercase or lowercase. For example, this expression
makes a Name field all lowercase:
Python
VBScript
LCase ([NAME])
JScript
[NAME].toLowerCase()
Convert your text labels to proper case. For example, this expression takes a Name field
that is in all capitals and makes it proper case:
Python
VBScript
JScript
Create stacked text. For example, this expression creates a label with the Name field and
the two address fields all on separate lines:
Python
VBScript
"Name: " & [NAME] & vbCrLf& [ADDRESS_1] & vbCrLf& [ADDRESS_2]
JScript
"Name: " + [NAME] + "\r" + [ADDRESS_1] + "\r" + [ADDRESS_2]
Create stacked text based on text from one field. For example, this expression uses the
comma to specify where the stack happens:
Python
VBScript
JScript
Format your labels. For example, this expression displays the label as currency:
Python
JScript
Specify a conditional if-else statement. These functions label cities with their name in a
large, red font if their population is equal to or exceeds 250,000 and in the default label
font if the population is less than 250,000:
Python
VBScript