ArcGIS Arcade: Are you ready to play?
Are you ready, Player 1, to rack up high scores? Get ready to enter your initials when you get the #1 spot with your Arcade mastery.
ArcGIS Arcade: A new game
ArcGIS Arcade is more than flashing lights, beeps and buzzers. It’s a helpful tool for making your maps and map information more presentable and dynamic.
Arcade was developed by Esri to be used across the ArcGIS system. It enables individuals to control and manipulate data and aspects of presenting data and information in many ways. Think of it like the codes used to solve riddles in old-school video games. If you’re an experienced coder, it’s similar to JavaScript and is lightweight and easy to work with. If you’re a newbie to this coding stuff, it’s one of the easier languages to learn. Knowing the fundamentals will go a long way to get you into the game and advance your usage of it.
Arcade is an expression language, meaning it is not used to write code for applications but is instead intended for things like calculations, altering visual variable properties and making on-the-fly decisions about how you want your data presented.
Like DOS did for PCs back in the day (MS-DOS 4 just went open source, incidentally), Arcade can be used across the ArcGIS system to replicate behaviours, actions and appearances in different maps or do very specific things depending on the context in which it is being applied.
Context is critical when it comes to Arcade. What I mean by context is where you’re using the Arcade expression. Many of these possible contexts will be outlined below. The important thing to remember is that the language stays the same, but what you can do with it will change based on where you are using the code. In Arcade-speak, we call the usage context a profile.
First life: Starting off
The most fundamental place to use an Arcade expression is when calculating field values in bulk. You can almost think of this as entering formulae in a certain unnamed spreadsheet program.
However, Arcade can be much more than just a formula. We can allow each expression to make decisions about specific attribute values, if desired. And this is where its real power lies.
We can also use Arcade to change the visual properties of features in a map, such as transparency, rotation, colour and size, similar to what we would do using attribute-driven symbology, but with more flexibility and the added power of decision making.
Second life: the boss
Arcade can be used to present label information, perform on-the-fly calculations, make decisions based on attributes, combine multiple attributes, stack text and more.
Arcade can make decisions on the fly and apply changes to labels.
We can affect the symbology of features and the entries displayed in the Catalogue pane/legend, as in the following example, where classification labels are applied to the legend and symbology by the expression.
Arcade can also be used to alter how information is presented in a pop-up by performing calculations dynamically, altering the colour of text-based attribute properties and more. The following example shows how Arcade can be used to apply conditional formatting within a pop-up based on an attribute value.
Third life: the big bad evil guy
With Arcade, you can go outside of the ArcGIS Pro or Online environments and begin working with form configuration for mobile apps such as ArcGIS Field Maps. These configuration options can be simplistic or more complex, embedding conditional behaviour in the form and making it responsive to user input.
Here we see an expression that dynamically populates a form field with the name of the user using the Field Maps application.
We can get into some really advanced things using Arcade, too, such as working with attribute rules in a feature class’s table. Attribute rules allow us to dynamically perform calculations, apply editing constraints and perform data validation on the fly by applying embedded expressions. The huge advantage of this is that the expression essentially becomes a part of the dataset, and anyone using that data will also, automagically, be using the attribute rules, thus allowing you to apply potentially rigorous QA/QC in an unattended manner.
There are three types of attribute rules:
Calculation: The expression is executed and returns the next sequence value for the new sewer drain cover feature.
Constraint: This expression is executed and returns a Boolean value to the Insert edit operation if the Type field is not completed, which causes the edit to fail.
Validation: This Arcade expression is used to set a validation rule for the Material field based on the Height field.
Arcade is particularly handy in ArcGIS Dashboards. Many different elements can have embedded expressions that are applied dynamically, in real time, the results of which can affect the data and information presented in the element, or even the appearance of the element itself.
The data used in an element can already be referenced by existing elements in the dashboard or be referenced explicitly by the expression as seen in the example below:
In this example, you see that certain entries in the list element are highlighted based on an attribute.
1-Up
Now we’re getting into some really funky stuff! With recent changes to the Arcade framework, we can even begin using HTML injection with our Arcade expressions. This allows us to reference many expressions simultaneously, apply HTML behaviours and so on when presenting data and resources to our users, as seen below.
Even the Esri Community is getting in on the act. There are community samples shared that present expressions for specific use-cases. For example, in the Community, use the search term “Using Arcade to Calculate the Slope of a Line” (the keyword “Arcade” is important), which would take you to the following sample: Using Arcade to Calculate the Slope of a Line. There you will find an explanation and code that you can bring into your own projects.
Where to turn from here? or "up up down down left right left right"
Arcade has the potential to be the ultimate cheat code. You just need to learn how to write the code to do what you want to do—just like those game tutorials we like to skip, there is a lot of value there.
I urge you to check out our course offerings below:
- ArcGIS Arcade: Join the Playground! To learn the fundamentals of Arcade syntax, this half-day course takes you right from dropping your quarter in the machine and teaches you how to write Arcade code from scratch.
- Get Started with ArcGIS Arcade: For detailed training on the different applications of Arcade, as shown above, this new two-day course takes you all the way to gaining that 1-up and racking up points.
So don’t ragequit. There are plenty of resources available to help you get that high score. Now, armed with all of this information and knowledge, get the training you need, get in some practice and get ready to enter your initials when you set that high score.
Want to stay informed about all the latest training opportunities at Esri Canada? Visit Esri Canada’s Communication Preference Centre and select the “Training” checkbox to get a monthly roundup straight to your inbox.