HOW TO

Calculate the intersected area of polygons using an Arcade expression in Portal for ArcGIS and ArcGIS Online Map Viewer

Last Published: April 6, 2023

Summary

Features overlap one another to demonstrate the spatial relationship between sublayers on a map, as shown in the image below. At times, it is necessary to determine the area of the intersection. This task can be completed using an Arcade expression in Portal for ArcGIS and ArcGIS Online Map Viewer. This article provides a workflow to calculate the intersected area of two polygon sublayers from a hosted feature layer in the web map using an Arcade expression.

The intersected polygons on the web map.

Procedure

  1. Open the web map in Map Viewer.
  2. On the Contents (dark) toolbar, click Layers The Layers icon..
  3. In the Layers pane, click the hosted feature layer with the two intersecting polygon sublayers.
  4. On the Settings (light) toolbar, click Pop-ups The Pop-ups icon..
  5. In the Pop-ups pane, under Options, click Manage expressions > Add expression.
Note: 
For ArcGIS Online, in the Pop-ups pane, click Attribute expressions > Add expression.
  1. In the dialog box, specify a name for the expression.
  2. In the Expression box, copy and paste the following expression.
    1. Set the necessary variables for the feature layer. Replace <polygon_layer2> with the name of the intersected polygon layer.
var blocks = Intersects(FeatureSetByName($datastore, "<polygon_Layer2>"), $feature);
var cnt = Count(blocks);
var intersectArea = 0;
  1. Calculate the area of intersection between polygons. Replace <unit of measurement> with the desired unit of measurement.
if (cnt > 0) {
    for (var block in blocks) {
        intersectArea += Area(Intersection($feature, block), "<unit of measurement>");
    } 
}

return Round(intersectArea, 2);
  1. Click Test.

The following code block demonstrates the full Arcade expression.

var blocks = Intersects(FeatureSetByName($datastore, "Polygon2"), $feature);
var cnt = Count(blocks);
var intersectArea = 0;

if (cnt > 0) {
    for (var block in blocks) {
        intersectArea += Area(Intersection($feature, block), "meter");
    } 
}

return Round(IntersectArea, 2);
The Arcade expression configured in the expression box.
Note: 
For ArcGIS Online, after copying and pasting the Arcade expression in the expression box, click Run.
  1. When the Results tab displays the area, click OK.
The area displayed under the Results tab.
Note: 
For ArcGIS Online, when the Output tab displays the distance, click Done.
  1. Click the Back The Previous icon. button next to Pop-up expressions or Attribute expressions (for ArcGIS Online).
  2. In the Pop-ups pane, click Fields list > Select fields.
  3. In the Select fields pane, check the newly created expression field, and click Done.
The expression field checked in the Select fields pane.

The image below shows the intersected area of the two polygons is 5643.11 meters.

The area of the intersected area on the web map pop-up.

Article ID: 000029915

Software:
  • ArcGIS Online
  • Portal for ArcGIS

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options