Why You Need (and Want) Arcade

This map highlights prison overcrowding in California using color (red, yellow, and green) and symbol size to indicate the degree to which each prison is over, at, or under capacity.

If you aren’t yet familiar with Esri’s new scripting language ArcGIS Arcade, you may be thinking, why do I need another scripting language?

The short answer is that you may not need Arcade, but once you find out all the nifty things you can do with this simple expression language, you are going to want to use (and reuse) it.

Arcade is not a full programming or scripting language for creating stand-alone apps. It is not a replacement for automation.

It is a focused, intuitive, and JavaScript-like language for creating expressions that customize visualization and labeling. Think of it more like a spreadsheet formula.

Because the ArcGIS platform is all about sharing—it runs on everything from desktops to mobile devices—coming up with an expression language that could run across the platform was challenging. To run on mobile devices, the language had to be lightweight. It also had to be secure. Some fully functional scripting languages introduce security issues.

To meet these requirements, Esri developed Arcade. Named for the covered passageway, not the video game haven, Arcade follows in the Esri tradition of naming scripting languages after streets and roads (like Avenue) and including an Arc in the name.

The result is a focused, secure, and portable language. An Arcade expression cannot be injected with executable code outside of its intended context. With Arcade, you can create expressions you can use without modification across the ArcGIS platform in ArcGIS Pro, ArcGIS Online, and applications developed with the ArcGIS Runtime SDKs and the ArcGIS API for JavaScript. For example, you could base visualizations off values returned from custom calculations in ArcGIS Pro, save them as web map items, and share those custom visualizations so that they can be consumed by other web, desktop, and mobile applications.

This multi-line Arcade expression classifies prisons as below, at, or above capacity based on each prison's average daily population divided by the prison's capacity.

With Arcade, you can easily perform calculations with layer fields and use the result for label expressions or data-driven visualizations. This means that when you are making a map and the layer you are using doesn’t contain the exact attribute field you need, you can generate that data on the fly without editing source data, adding a field, or permanently calculating values.

With this capability, you can turn counts into percentages, derive new values from provided data, and otherwise turn the raw data behind your map features into information for your map reader. Arcade expressions can also set rendering properties such as transparency and rotation. This is especially useful for ArcGIS Online maps. Simply choose Change Style > New Expression, and construct your expression in the scripting window.

Arcade is purposefully simple. Instead of the many programming constructs found in other languages, it has a rich library of data, logical, mathematical, geometry, date, and text functions that make it easy to do complex calculations. The Arcade team at Esri will continue to extend the language with requested functions that meet use case needs.

Because it is case insensitive, it does not matter if you mix the case of variable and function names. Arcade’s type system implicitly casts between types where appropriate using a predefined set of rules.

Use Arcade for single-line or multiline expressions. Either way, it will return the last statement even if the keyword return is not used (except in the case of custom functions). With Arcade, geospatial is a first-class citizen. Geometries can be created and referenced. Arcade has profiles for visualization, labeling, and alias. A profile is the context in which an Arcade expression is evaluated. Each profile expects different inputs and produces different outputs.

There are lots of resources for learning Arcade. In addition to the guide and function reference, the site has a playground section for testing and fooling around with Arcade expressions. Visit the site today and start learning Arcade, a simple-to-write and quick-running language that will help you easily create more powerful information products.