Arcade Expression
Arcade Expression
Tyson Quink
Topics
What we’re doing here…
• Overview of Arcade
- What is Arcade
- Why use Arcade
• Arcade Languages
- Variables, Functions, Loops, Conditional Statements
• Arcade
- Using Arcade
Arcade is an expression language that can be used across
the ArcGIS Platform. Whether writing simple scripts to control
how features are rendered, or expressions to control label
text, Arcade provides a simple scripting syntax to deliver
these capabilities.
Arcade
Arcade
• Embedded Expressions
- Labeling, Rendering, Symbol Variations, …
- Sharing
Online Enterprise
• Portable
- Write an expression in ArcGIS Pro and have it work across the platform
• Secure
var mapPoint = true;
- Expression has no impact on security
if (mapPoint){
return "Star“;
• Lightweight } else {
return "Circle“;
- The language should be small and fast }
• Geospatial
- GIS data is the main use case
Arcade Language
What’s available
Functions
Data Functions Date Functions Geometry Functions Logical Functions Mathematical Functions
• Console • Date • Area • IsEmpty • Abs
• Count • DateAdd • AreaGeodetic • DefaultValue • Acos
• Dictionary • DateDiff • Buffer • When • Asin
• Distinct • Millisecond • BufferGeodetic • Decode • Atan
• DomainCode • Second • Centroid • IIf • Atan2
• DomainName • Minute • Clip • Boolean • Average
• Feature • Hour • Contains • Ceil
• FeatureSet • Month • Crosses • Constrain
• FeatureSetById • Weekday • Cut • Cos
Text Functions
• FeatureSetByName • Year • Difference • Exp
• Concatenate
• FeatureSetByPortalItem • Day • Disjoint • Floor
• Find
• Filter • Now • Distance • Log
• Lower
• First • Today • Equals • Mean
• Left
• Guid • Timestamp • Extent • Min
• Mid
• HasKey • ToLocal • Geometry • Max
• Proper
• IndexOf • ToUTC • Intersection • Pow
• Replace
• IsNan • Intersects • Random
• Right
• NextSequenceValue • Length • Round
• Split
• Number • LengthGeodetic • Sin
• Trim
• OrderBy • MultiPartToSinglePart • Sqrt
• Upper
• Reverse • Multipoint • Stdev
• Sort • Overlaps • Sum
• Text • Point • Tan
• Top • Polytline • Variance
• TypeOf • Polygon
• SetGeometry
• SymmetricDifference
• Touches
• Union
• Within
Global Variables and Profiles
• Arcade scripts run and return a value. They are self contained and cannot alter their
environment.
Case Insensitive
• Language is case insensitive UpPeR(‘Hello World’)
- Quicker to author $feAtuRe.FiElD_nAmE
- Simpler for working with data and field
names
Type System
• Simple Types
var myNumber = 10;
- Numbers
var myText = "Hello";
- Booleans
var myDate = Date(2015,1,1);
- Dates var myBool = true;
- Strings var myDictionary = {"key1": 10};
var myFeatures = Feature({"geometry":{...},
• Object Types "attributes":{"key1": 10}});
- Dictionary var myArray = [1, 2, 3];
- Feature var myPoint = Point({...});
- Array
- Point Dates, Dictionary, Feature, Point, Line….all have
overloaded constructors.
- Line
- Polygon
- Multipoint
Implicit and Explicit Type Casting
• Implicit Casting
Implicit Casting:
- For Function Parameters
- For Expressions
return 10 + "Star"
• Explicit Casting
Explicit Casting:
- Functions cast between types
return text(10) + "Star"
- Number, Text, Date, Boolean
if Statement
Traditional if Statement:
if (mapPoint){
• if statements are supported return ‘Star’;
} else {
• Simple single line expressions return ‘Circle’;
- IIF }
- Decode
- When Equivalent:
IIF(mapPoint, ‘Star’, ‘Circle’);
for Statement
for(var i=1; i<100; i++) {
• for Statements if (i==3) continue;
- Same syntax as JavaScript
if (i==5) break;
• for in Statements
n+=i;
- Iterates over indices of an array, or field
}
names of a Dictionary or Feature
for(var k in myArray) {
• Break, Continue, Return Statements n+=myArray[k];
supported inside block }
User Defined Functions
Since Arcade expressions execute for each feature, using multiple geometry operations
within the context of the labeling and visualization profiles can be expensive and
severely impact the performance of the application. Also note that geometries fetched from
feature services, especially polylines and polygons, are generalized according to the view's
scale resolution. Be aware that using a feature's geometry (i.e. Geometry($feature)) as
input to this function will yield results only as precise as the view scale. Therefore, results
returned from geometry operations in the visualization and labeling profiles may be different
at each scale level. Use these functions at your discretion within these contexts.
Feature Sets
Field Calculations
<script>
var windArcade = document.getElementById("wind-direction").text;
• Create Buffers
• Reconstruct Tracks
• Join Features
• Detect Incidents
• Calculate Field
Arcade
Platform Language
Resources
Arcade Documentation
https://developers.arcgis.com/arcade/
Playground
https://developers.arcgis.com/arcade/playground/
Tuesday Wednesday
12:30 pm – 6:30 pm 10:45 am – 5:15 pm
GIS Solutions Expo GIS Solutions Expo
Hall D Hall D