Getting Started
Introduction
Arcade is a portable, lightweight, and secure expression language used to create custom content in ArcGIS applications. Like other expression languages, it can perform mathematical calculations, manipulate text, and evaluate logical statements. It also supports multi-statement expressions, variables, and flow control statements. What makes Arcade particularly unique when compared to other expression and scripting languages is its inclusion of feature and geometry data types.
An Arcade expression written in one ArcGIS application can be consistently interpreted in other ArcGIS applications. For example, an expression defining popup content in ArcGIS Pro can be saved to a web map and executed in a mobile application developed with ArcGIS Runtime, or in a web app, such as ArcGIS Online, and the ArcGIS API for JavaScript.
Hello world
The following example contains a single statement that evaluates to a string.
'Hello World'
A more common use of Arcade is for performing a calculation with layer fields and using them for label expressions or data-driven visualizations. In the snippet below the expression references the $feature
global variable. This represents a feature from a service or a layer, and contains a geometry and set of attributes. The expression below accesses a field named landValue
and multiplies it by 100
.
$feature.landValue * 100
Returning values from your script
Implicit returns allow Arcade to be used for simple, single-line expressions and also for full multi-statement scripts.
In multi-line expressions, Arcade will return the last statement even if the keyword return
is not used. This is referred to as an implicit return.
// explicit return
return ($feature.POP_2010 / $feature.POP_2000) * 100
// implicit return
($feature.POP_2010 / $feature.POP_2000) * 100
// explicit return
var myArray = [10,20,30,40,50,60,70];
var sum = 0;
for(var k in myArray){
sum += myArray[k];
}
return sum;
// implicit return
var myArray = [10,20,30,40,50,60,70];
var sum = 0;
for(var k in myArray){
sum += myArray[k];
}
sum;
Functions and profiles
Arcade does not have many of the programming constructs that exist in other programming languages. Instead, it has a rich library of functions to simplify the process of calculating values.
Arcade is used throughout the ArcGIS system to provide a portable mechanism for defining and sharing expressions. These expressions will run in the desktop, on the web, or on mobile devices. There are several profiles, or contexts, in which Arcade is used throughout ArcGIS applications.
Each profile defines the parameters that are available to the script as global inputs, and the output expected from the script. For example, when using the labeling profile a global $feature
input is referenced containing the feature to be drawn. Attributes from this feature can be referenced and returned as text for the label.