ArcGIS Arcade: Calculate Fields like Never Before

By Katherine

In the extensive realm of geographic information systems (GIS), the Esri ArcGIS platform offers a plethora of tools to analyze and manipulate data. One of these powerful tools is ArcGIS Arcade, a concurrent, rule-based expression language for computing field values. This language, designed with ArcGIS, empowers users to perform complex calculations, making it a vital component for streamlining workflows and enhancing map output.

Tips for Using the Field Calculator in ArcGIS
Tips for Using the Field Calculator in ArcGIS

ArcGIS Arcade's versatility lies in its ability to execute calculations on various data types, including text, number, date, and boolean. It can perform operations such as adding, subtracting, concatenating, and transforming data, leading to more informed decisions and visually appealing maps.

How to Add Data from ArcGIS Online to QGIS
How to Add Data from ArcGIS Online to QGIS

Understanding Arcade Expressions

Before delving into calculations, it's essential to grasp the fundamental structure of Arcade expressions. These are composed of operators, functions, and variables, which run concurrently, allowing for efficient processing of large datasets.

My Road to Pro: A guide to getting up and running with ArcGIS Pro in a 'Redlands Minute'
My Road to Pro: A guide to getting up and running with ArcGIS Pro in a 'Redlands Minute'

Arcade expressions follow simple syntax rules. They must begin with an "=" operator that designates the result of the expression, followed by one or more operators and functions, and concluded with a trailing semicolon (;). Understanding this syntax is key to constructing effective Arcade scripts.

Operators and Functions in Arcade

Top 10 ArcGIS Pro Tutorial Lesson
Top 10 ArcGIS Pro Tutorial Lesson

Operators in Arcade serve to perform actions on variables and values, such as arithmetic operations (+, -, *, /), logical operations (AND, OR, NOT), and comparison operations (<, >, <=, >=, ==, !=). Functions, on the other hand, perform more complex operations and often include the use of inputs or arguments.

Esri provides a comprehensive list of built-in functions in the Arcade documentation, categorized by their functionality, such as date, list, math, and string operations. Additionally, Arcade supports user-defined functions, offering endless possibilities for custom operations.

Calculating Fields: A Crucial Task

QGIS vs ArcGIS Pro
QGIS vs ArcGIS Pro

Calculating field values is a pivotal task in GIS analysis. It enables users to derive new information from existing data, facilitating better understanding and communication of geographic patterns. Arcade's capacity to compute field values concurrently across features makes it an ideal choice for calculating fields in ArcGIS.

To calculate a new field using Arcade, simply open the attribute table of your layer, right-click on its header, and select "Calculate Geometry" or "Calculate Attribute." This triggers the Arcade expression editor, where users can input their custom calculations and define the output field's name, data type, and other properties.

Arcade Expressions: Examples and Best Practices

Converting ArcGIS Layers to Google Earth (KML) - Duke Libraries Center for Data and Visualization Sciences
Converting ArcGIS Layers to Google Earth (KML) - Duke Libraries Center for Data and Visualization Sciences

To illustrate Arcade's calculating capabilities, let's consider a few examples and best practices. Suppose you have a point layer representing various flora with attributes: 'Name', 'Type', 'Height', and 'Location'. You want to create a new field, 'Estimated_AGE', which calculates the technological age of each plant, defined as '2022 - Year_Of_Discovery'.

A suitable Arcade expression for this could be: `2022 -Year_Of_Discovery;`. In this instance, 'Year_Of_Discovery' is a variable, and '2022' a constant integer. Arcade will concurrently calculate the technological age for each plant in the layer.

Tutorial Gallery | Documentation
Tutorial Gallery | Documentation
How To Add a Locator Map in ArcGis
How To Add a Locator Map in ArcGis
ArcNews Fall 2004 Issue -- ArcGIS Raster Data Models
ArcNews Fall 2004 Issue -- ArcGIS Raster Data Models
Tutorial: Get started with arcpy.mp | ArcGIS Pro documentation
Tutorial: Get started with arcpy.mp | ArcGIS Pro documentation
ArcGIS10 Basics 2 of 4
ArcGIS10 Basics 2 of 4
Getting Started with ArcGIS Pro
Getting Started with ArcGIS Pro
What is ArcGIS?
What is ArcGIS?
What's New in ArcGIS Online (December 2016)
What's New in ArcGIS Online (December 2016)
ArcGIS Urban 101 – Projects and Plans
ArcGIS Urban 101 – Projects and Plans
How to Perform Location Allocation Analysis in ArcGIS Pro
How to Perform Location Allocation Analysis in ArcGIS Pro

Concatenating Strings and Numbers

Arcade can also concatenate text and numbers using the "&" operator. For instance, want to create a 'Full_Description' field that combines 'Name', 'Type', and 'Height' into a single text field. An appropriate Arcade expression would be: `'Name' & ' is a ' & 'Type' & ' that is ' & toText('Height') & ' meters tall';`.

Note the use of 'toText' function to convert the 'Height' numeric value to text, ensuring proper concatenation with the other string variables.

Advanced Calculations: Using User-defined Functions

For more intricate calculations, users can create their own functions. Suppose we want to categorize our plants into height-based categories (e.g., 'Small' if 'Height' < 1, 'Medium' if 'Height' >=1 and '<=3', and 'Tall' otherwise). A suitable user-defined function could be: ```python function Height_Category() { if ('Height' < 1) { return 'Small'; } else if ('Height' <= 3) { return 'Medium'; } else { return 'Tall'; } }; ``` And the Arcade expression to calculate a new 'Height_Category' field would be: `Height_Category();`. This illustrates Arcade's potential in performing complex calculations and enhancing your GIS projects.

In your GIS journey, ArcGIS Arcade's calculating power is a tool you won't want to ignore. Continuously exploring its vast capabilities will open doors to more insightful analysis and visually striking maps. So, start calculating, start.ArcGIS!"