Arcade is an expression scripting language which can be used across the ArcGIS Platform on feature layers. It can perform mathematical calculations, manipulate text, and evaluate logical statements using your data.
Arcade transforms your data values on-the-fly and can be used for your map symbology, labels, transparency, pop-ups, and symbol rotation. Do basic calculations, convert field types, and even create complex equations using your data. All without leaving the map.
Within Map Viewer I have data from the US Census Bureau with 2000 and 2010 population counts. Traditionally, I'd have to own the data layer, go back to ArcGIS Pro, and calculate a new field in order to see the change in population between the two years. However, with Arcade, I can do this on-the-fly by creating an expression directly within the map.
To map a new value using an expression, choose "New Expression" at the bottom of your attribute list:
The expression window will appear on the screen. The equation for change over time is ( (new - old) / old ) * 100, so I simply type this into the Expression window using the existing attributes from the data.
Arcade will map the resulting value from this expression, so now I can make adjustments to the cartography and show my new "Change in Population from 2000 to 2010" value. I chose to set 10% growth as dark blue, and 10% decline as dark red.:
Apart from your cartography, Arcade can also be used in the following ways within Map Viewer:
Use Arcade to calculate or convert your attributes. The Arcade window contains your existing attributes, which you can use to calculate new values.
The graphics below introduce the basic layout of the Arcade window:
I have a dataset of energy pipelines in Indiana. One attribute I'm interested in mapping is the diameter of these pipelines. Unfortunately, this value was hosted as a text field rather than a number. Previously, I would need to go back to my data table and calculate a new field using a numeric field type.
Fortunately, I have the power of Arcade to transform this attribute on-the-fly! There is a Number() function which easily makes this conversion.
Smart mapping will recognize the result of the expression as a numeric value, so now I'm able to visualize the width of the pipelines using the size of the symbols:
The following scenario walks through a few of the ways Arcade can be accessed within Map Viewer. In this example, I'll create a map from scratch. Keep these techniques in mind when working with your own hosted data.
Here we see cities in Texas as points on the map. These points contain data about the city's sales tax payments from 2014 and 2015. I'd like to map the trend of these payments but did not pre-calculate anything before hosting this data.
Instead of going back to the raw data, this is the perfect time to use Arcade!
To get started with our map, we'll start by diving into the "Change Style" option.
When choosing an attribute to show on the map, scroll to the bottom of the list of attributes where you will see "New Expression".
This option allows you to create a new expression using the attributes from your hosted data.
The following window appears, which allows you to write your own custom expression.
The word "Custom" that appears at the top of the window is the title of your expression. This is also what appears in your map's legend, so make sure to rename this to match your final expression.
For this map, I want to compare the 2014 and 2015 tax payments to see if there was an increase.
I use if/else logic to determine what the expression will return. In this case, I want to return the string "Increase" if the value went up over time or "Decrease" if the value went down.
Now, my map shows which cities had an increase or decrease in tax payments.
Within the Options, I can use a custom image as my point symbol to help make the map more clear.
But let's go a few steps further with expressions to make this map tell a captivating narrative about the data.
We can use an expression to flip the "Decrease" symbols to point downward, by writing another expression.
Start by selecting the checkbox to "Rotate symbols" which appears on point layers.
Choose "New Expression" from the attribute list, as you did before, to create the expression.
If you want to make edits to your expression once you have written it, click the pencil symbol.
This expression creates a positive rotation if there was an increase in taxes (90 degrees) and a negative rotation if there was a decrease (-90 degrees).
This blog provides more information about setting symbol rotation for your point symbols.
Next, we will explore the use of expressions for labeling.
Hopefully, this pattern is starting to look familiar!
In the labels pane, choose "New Expression" from the attribute list.
This time, we will choose to use an existing expression rather than creating a new one. Any expressions you have created on a layer are re-usable.
Our map is really shaping up! Keep in mind that none of the settings we have used in this map existed prior to the creation of this map.
Let's finish our map with a custom pop-up using expressions.
Pop-ups allow the use of multiple expressions, which are handled as if they are a new attribute within the data.
The "ADD" button will bring up the same Arcade window we have seen in the other examples. In this case, I created an expression for increases in sale tax and another expression for decreases.
Your pop-up expressions can be configured just like any other attribute using the "Configure Attribute" option.
Once you write your expression(s), it can be added to your pop-up just like any other attribute from your data.
This blog provides more information about creating custom popups.
Using Arcade expressions, we were able to create this fully custom map without any pre-processing of the data.
Arcade expressions open many doors for the customization of your maps. Save time and processing steps by writing simple (or complex) expressions to showcase your data. The possibilities are endless!
Everything you've seen in this story map can be configured within a web map and used "as is" in a configurable app or custom app. Developers can do even more by working within the API. See the blogs for developer examples.
To learn more about Arcade, check out the following resources:
For more inspiration, check out the resources and maps below to see how others are using Arcade within their maps and apps.
Explore the settings used within these maps and apps to gain inspiration for your own maps!
An error has occurred |