Using custom expressions in ArcGIS Online

11704
3
01-06-2017 07:03 AM
JosephKerski
Esri Notable Contributor
9 3 11.7K

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. 

Tags (2)
3 Comments
About the Author
I believe that spatial thinking can transform education and society through the application of Geographic Information Systems for instruction, research, administration, and policy. I hold 3 degrees in Geography, have served at NOAA, the US Census Bureau, and USGS as a cartographer and geographer, and teach a variety of F2F (Face to Face) (including T3G) and online courses. I have authored a variety of books and textbooks about the environment, STEM, GIS, and education. These include "Interpreting Our World", "Essentials of the Environment", "Tribal GIS", "The GIS Guide to Public Domain Data", "International Perspectives on Teaching and Learning with GIS In Secondary Education", "Spatial Mathematics" and others. I write for 2 blogs, 2 monthly podcasts, and a variety of journals, and have created over 5,000 videos on the Our Earth YouTube channel. Yet, as time passes, the more I realize my own limitations and that this is a lifelong learning endeavor and thus I actively seek mentors and collaborators.