Getting Started

Introduction

Arcade is a portable, lightweight, and secure expression language written for use in the ArcGIS platform. 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. Arcade was designed specifically for creating custom visualizations and labeling expressions in the ArcGIS Platform. It allows users to write, share, and execute custom expressions in ArcGIS Pro, ArcGIS Runtime, ArcGIS Online, and the ArcGIS API for JavaScript.

What makes Arcade particularly unique to other expression and scripting languages is its inclusion of feature and geometry data types. In the initial release of Arcade, geometries can be created and referenced. In future releases, other geometry functions may be added allowing you to calculate areas and lengths, and perform simple overlay operations in more complex expressions.

While the syntax contains similarities to other scripting languages, Arcade is not designed for writing standalone apps. It is intended solely for evaluating embedded expressions such as those used in the visualization, labeling, popup, and alias contexts of applications built with the ArcGIS platform. This includes apps developed with the ArcGIS Pro and Runtime SDKs, 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 is simple and does not have many of the programming constructs that exist in other programming languages. Instead, it has a rich library of functions that make it easy to author complex calculations.

Arcade is used throughout the ArcGIS Platform 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 the ArcGIS platform.

Each profile defines the parameters that are available to the script as global variables, and the output expected from the script. For example, when using the labeling profile a global variable is referenced containing the feature to be drawn, and returns the label text to display.


Feedback on this topic?