0% found this document useful (0 votes)
51 views

Arcade Expression

ArcGIS Arcade is a lightweight expression language designed for use across the ArcGIS platform, enabling users to create simple scripts for feature rendering and labeling. It supports various programming constructs such as variables, functions, and loops, while being portable and secure. The document outlines the language's features, functions, and practical applications in GIS data visualization and analysis.

Uploaded by

Chaluvadi Laxman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Arcade Expression

ArcGIS Arcade is a lightweight expression language designed for use across the ArcGIS platform, enabling users to create simple scripts for feature rendering and labeling. It supports various programming constructs such as variables, functions, and loops, while being portable and secure. The document outlines the language's features, functions, and practical applications in GIS data visualization and analysis.

Uploaded by

Chaluvadi Laxman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

An Introduction to ArcGIS Arcade

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

• Arcade is NOT intended to be a Full Programming / Scripting Language Apps

- Lightweight and Simple


- Similar to spreadsheet calculations Desktop
APIs

• Embedded Expressions
- Labeling, Rendering, Symbol Variations, …
- Sharing
Online Enterprise

Not a replacement for geoprocessing and automation


Challenge

Mobile Challenge Browser Challenge Scripting Challenge

• Size of Executables • Page Size


• Security • No Binaries
• Native Access • Security
• XSS
Arcade Goals

• 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

Alias Attribute Rules Feature Z Field Calculate


Allows the map author Attribute Rule Calculation Use expressions to Use expressions to
to write an expression to Attribute Rule Constraint calculate z values for update a field value
evaluate a numeric value Attribute Rule Validation features in a 3D scene. based on expression
and return a string alias
logic.
representing that value.
Global Variables Global Variables Global Variables
Global Variables • $feature • $feature • $feature
• $value • $datastore • $layer
• $datastore

Labeling Popup Visualization

Use expressions to Use expressions to Use expressions to


determine the label to return values for display evaluate a value used to
show on the map for in the popup. drive the visualization. Future Profiles
each feature. Global Variables
Global Variables • $feature Global Variables
• $feature • $layer • $feature
• $map • $view.scale
• $datastore
Hello World
Sample Name Here
Language Features
• Designed for Simple Expressions
- Single Line – Implicit Returns
- Case insensitive Language
- Dictionary Syntax for Field Access

• Has language features to support more complex scripts


- Type system
- Implicit and Explicit type casting
- Flow control statements: if, for
- Variable declaration and assignments
- User defined functions

• 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

• Function keyword used to declare function MultiplyNumber(number) {


functions
return number * 50;
- Must be declared ahead of use
}
- Variables defined inside function have
local scope
- Functions cannot be declared inside of MultiplyNumber(10);
functions
Variable Assignments

• Variables can have their values


reassigned ++myNumber
- Objects types may be immutable if i = i + 1;
passed into Arcade myArray[10] = 11;
- Arrays are not Sparse. They must be myFeature.Field1 = 'arcgis';
sequential
- Geometry types are immutable inside.
You cannot change the points in a path
of a line.
Rendering
Attribute Symbolization

The visualization profile allows the map author to write an


expression that evaluates to a value used to drive the visualization.

var dem = $feature.votes_dem;


var rep = $feature.votes_gop;

if (dem > rep) {


return "Democrat“;
} else {
return "Republican“;
}
Arcade Symbology
Geometry Functions

var json = {"x":-77.009268,"y":38.889750 ,"spatialReference":{"wkid":4326}};


var source_point = Point(json);
var feature_point = Geometry($feature);
var dist = Distance(feature_point, source_point, 'meters');
return dist;
Geometry Functions
Warning

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

var crime = FeatureSetByPortalItem('fa2988a7cc2b4bc4beefc132e07b9d80', 0);


var crimeCount = Count(Intersects(crime, $feature));
return crimeCount;
Arcade Geometry
Labeling

When the label is to be drawn, the script


will be evaluated. It will be passed the
var windSpeed = $feature.WIND_SPEED;
feature that is about to be labeled. It is var temp = $feature.TEMP;
expected that the script returns a text var windChill = Round(35.74 + (0.6215*temp) -
string, comprising the label to be drawn. 35.75*POW(windSpeed,0.16) + 0.4275*temp*POW(windSpeed,0.16), 2);

if (windChill <= 32) {


return '<CLR blue = "255">Wind Chill: '+ windChill + '°</CLR>';
} else if (windChill >32 && windChill <= 55) {
return '<CLR yellow = "255">Wind Chill: '+ windChill + '°</CLR>';
} else {
return '<CLR red = "255">Wind Chill: '+ windChill + '°</CLR>';
}
Popups

// return the value to the map, to be mapped


IIf(total > 0 && domAttainment == "Irish", domAttainment, null);
Arcade Pop-ups
<script type="text/plain" id="wind-direction">

JavaScript // WIND DIRECTION

Using Arcade var DEG = $feature.WIND_DIRECT;


var SPEED = $feature.WIND_SPEED;
var DIR = When( SPEED == 0, null,
(DEG < 22.5 && DEG >= 0) || DEG > 337.5, 'N',
DEG >= 22.5 && DEG < 67.5, 'NE',
DEG >= 67.5 && DEG < 112.5, 'E',
DEG >= 112.5 && DEG < 157.5, 'SE',
DEG >= 157.5 && DEG < 202.5, 'S',
DEG >= 202.5 && DEG < 247.5, 'SW',
DEG >= 247.5 && DEG < 292.5, 'W',
DEG >= 292.5 && DEG < 337.5, 'NW', null );
var WIND = SPEED + ' mph ' + DIR;
return WIND;
</script>

<script>
var windArcade = document.getElementById("wind-direction").text;

var windClass = new LabelClass({


labelExpressionInfo: {
expression: windArcade
},
labelPlacement: "above-right",
minScale: 2500000
});
windClass.symbol = createTextSymbol("#3ba53f", 11, { x: 3, y: 3 });
</script>
GeoAnalytics
Arcade in analysis

• 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/

Using Arcade in JS API


https://developers.arcgis.com/javascript/latest/guide/arcade/index.html

Using Arcade in GeoAnalytics Server


https://enterprise.arcgis.com/en/server/latest/get-started/windows/geoanalytics-calulate-field-expression.htm
Print Your Certificate of Attendance
Print Stations Located at L Street Bridge

Tuesday Wednesday
12:30 pm – 6:30 pm 10:45 am – 5:15 pm
GIS Solutions Expo GIS Solutions Expo
Hall D Hall D

5:15 pm – 6:30 pm 6:30 pm – 9:00 pm


GIS Solutions Expo Social Networking Reception
Hall D National Museum of
Natural History
Please Take Our Survey on the App
Download the Esri Events Select the session Scroll down to find the Complete answers
app and find your event you attended feedback section and select “Submit”

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy