Discover answers to commonly asked questions about ArcGIS Arcade.
You may find yourself asking, "Why did Esri bother writing its own language when it probably could have used others, like Python?" This decision was made because we needed an expression language that met the following requirements:
- Lightweight and simple - A language with a small number of functions and an easy syntax.
- Portable - A language that can execute in multiple environments with the same syntax for web, desktop, and mobile apps.
- Secure - A language that doesn't have security vulnerabilities that open the door to malicious scripts.
- Geospatial first - A language that makes geospatial functions and capabilities first-class citizens.
For example, in the context of the popup profile, Arcade can be used to calculate values client-side for a popup.
// displays the % change between two attributes for the popup var pop2020 = $feature.POP_2020; var pop2010 = $feature.POP_2010; var perChange = ( ( pop2020 - pop2010 ) / pop2010 ); // implicitly casts the number as a text value return Round( perChange ) + "%";
The dollar sign
$ character prefixes all profile variables. This helps the expression author know how to differentiate external inputs to the expression from variables declared within the expression.
// $feature gives you access to attribute values // so you can use them in calculations $feature.POPULATION / $feature.SQ_MILES; // $feature is a point geometry var featureGeometry = Geometry($feature); // returns the x-coordinate of the geometry featureGeometry.x
See the Profile variables documentation for more information.
You can use geometry functions in any profile that includes the geometry function bundle. Keep in mind that some profiles, such as visualization, generalize geometries to improve performance. Therefore, geometry calculations will lose precision as geometries become more and more generalized (as you zoom out).
For example, calculating a the area of a parcel when zoomed out to the extent of a county will yield a less precise result than if you calculate the area of the same polygon when zoomed to the polygon's extent.
There are several different ways to handle
null values in your data. A common workflow is to remove or replace fields with empty values in a popup table. The IsEmpty() and DefaultValue() functions can help you handle these situations.
Map services allow you to create dynamic table joins. Arcade can reference data in a joined table within a map service using the square bracket notation for field names:
// Election data for 2016 in one table named "election2016" // Election data for 2012 in another table named "election2012" var demVotes2016 = $feature["election2016.VOTED_DEM"]; var demVotes2012 = $feature["election2012.VOTED_DEM"]; // returns % change in votes from 2012 to 2016 Round( ( ( demVotes2016 - demVotes2012 ) / demVotes2012 ) * 100, 2);
Yes. You can access data from other layers using FeatureSet functions depending on the profiles that support them.
An Arcade expression is portable as along as the functions and syntax used in it are supported in the versions of Arcade included in the apps executing the expression.
Another example is
$feature casting to
Geometry in geometry functions. In Arcade version 1.4, the following expression is valid:
Area( $feature, "kilometers" )
But it is not valid in Arcade version 1.3. Arcade 1.3 doesn't automatically cast a feature to a geometry, so you will need to cast the geometry yourself to ensure portability.
Area ( Geometry($feature), "kilometers" )
Also note that geometry functions weren't supported until Arcade 1.3, so neither of the expressions will work if you attempt to use them in an app that uses Arcade 1.2 or prior.
To ensure portability, you should try to use apps including the latest version of Arcade where possible. You can find which versions of Arcade are used by each product/API in the Version matrix.
You can publicly share Arcade expression templates with others in the Esri/arcade-expressions GitHub repository. This repository is intended for sharing and maintaining reuseable Arcade expressions across all supported profiles.
No. When working with multiple geometries using geometry functions, their spatial references must match. The spatial reference of all geometries must match the spatial reference of the map or service executing the expression as well.
See the Your Arcade Questions Answered blog post.