ArcGIS Pro, a powerful desktop GIS application, provides an extensive suite of tools to manage, analyze, and visualize spatial data. One of its standout features is its ability to perform calculations on fields, transforming and enriching data in real-time. The Arcade expression language is at the heart of these calculations, offering a wide range of functions to create sophisticated calculations. Let's delve into some practical examples of how you can leverage Arcade to perform field calculations in ArcGIS Pro.
Before we dive into the examples, let's ensure that our data is ready. You should have your data loaded into ArcGIS Pro, and the fields you want to calculate should be selected or edited.
Calculating New Fields
One common use of Arcade is creating new fields based on existing ones. This is useful when you want to derive new data from your existing attributes without affecting the original data.
To illustrate, let's say we have a point feature class of buildings with 'FloorArea' and 'NumBedrooms' fields, and we want to calculate a new field 'ValuePerSquareFoot'.
Example 1: Division Calculation
We can use the divide function in Arcade to perform this calculation. The Arcade expression would look like this:
In ArcGIS Pro, you would paste this expression into the 'cible' field's expression builder, choose the appropriate data type (like 'Double'), and click 'OK'.
Example 2: String Concatenation
Arcade also supports string concatenation, which is handy when you want to combine text from different fields. For instance, if we have 'BuildingName' and 'UnitNumber' fields, we can create a new 'FullAddress' field with the following Arcade expression:
```html BuildingName + ' - Unit ' + UnitNumber ```This will return 'Example Tower - Unit 101' if 'BuildingName' is 'Example Tower' and 'UnitNumber' is 101.
Conditional Statements
Arcade supports conditional statements using if-else syntax, allowing you to create rules and definitions in your data. Let's see how we can use this to categorize buildings based on their floor area.
We want to create a new field 'SizeCategory' that categorizes buildings as 'Small', 'Medium', or 'Large' based on their floor area. Assume 'Small' is less than 1000 sq ft, 'Medium' is between 1000 and 5000 sq ft, and 'Large' is 5000 sq ft or more.
Example 3: If-Else if-Else Statement
The Arcade expression for this would be:
This expression uses nested if-else statements to define the size categories based on the 'FloorArea' field.
Example 4: Switch Statement
Alternatively, you can use the switch statement to achieve the same result in a more concise way:
```html switch( true, FloorArea < 1000, 'Small', FloorArea > 5000, 'Large', 'Medium') ```In both examples, the new field 'SizeCategory' will be populated based on the rules defined in the Arcade expression.
With these examples, you've seen how Arcade can be used to perform various kinds of field calculations in ArcGIS Pro. From simple divisions to conditional statements, Arcade offers a wealth of functionalities to help you manage and derive insights from your data. Now, it's your turn to explore and experiment with Arcade to unlock its full potential for your specific use cases.