jkerski-esristaff

Using custom expressions in ArcGIS Online

Blog Post created by jkerski-esristaff Employee on Jan 6, 2017

Writing a custom expression in ArcGIS Online using the new Arcade scripting language is easy, powerful, and has deep implications for education.  Arcade expressions, described in full here, allow you to make maps from simple calculations, from functions, from data conversions, and from brand new representations of your data.  In my example below I wrote an expression that symbolizes cities based on the percentage of 18 to 29 year olds in that city.  But this blog essay shows that more advanced and powerful expressions, such as if-then statements, are possible.

 

Under "Change Style" is where you enter the expression, under "Custom (Expression)" as follows:

The custom script in ArcGIS Online

My expression to calculate the percentage of 18 to 21 plus 22 to 29 year olds out of the total population for each city in my data set is:

 

Round ((($feature.AGE_22_29 + $feature.AGE_18_21) / $feature.POP2000) * 100, 2)

 

Here is my resulting map:

http://www.arcgis.com/home/webmap/viewer.html?webmap=b90ad50f16ec4af6bac778bda7aec5ac

 

Final map from script results.

One of the chief advantages of expression building is that the data that you are seeking to map does not already have to be part of the existing attribute table for your data - you are, in a sense, creating that data with your expressions!  And teaching students how to write these expressions to achieve a desired result builds skills in GIS, computer science, and mathematics. 

Outcomes