HOW TO

Display the total length of lines within a polygon in a pop-up based on field values using Arcade in ArcGIS Online

Last Published: May 9, 2024

Summary

In ArcGIS Online, it is possible to calculate the total length of lines within a polygon based on field values and display the results in a pop-up using an Arcade expression. This is useful in understanding spatial relationships and patterns.
In this article, an Arcade expression is used to calculate the total length of the active roads within a neighborhood based on their status, and the result is then displayed in a pop-up. The image below displays the attribute table of the line feature layer representing the roads within the neighborhood.

The attribute table displaying the line feature layer fields.

Procedure

  1. Open the web map in Map Viewer.
  2. In the Layers pane, select the layer. In this example, a polygon layer named ‘Neighborhood’ is used.
  3. On the Settings (light) toolbar, click Pop-ups. Ensure pop-ups are enabled by toggling Enable pop-ups on.
  4. In the Pop-ups pane, create an Arcade expression to calculate the total length of lines within the polygon layer based on field values. Refer to ArcGIS Online: Use expressions for instructions.
  5. In the editor window, configure the expression below.
Length(Contains($feature, Filter(FeaturesetByName($datastore, '<feature_name>', ['*']), "<field_name> = '<field_value>'")))
  1. Replace <feature_name> with the name of the line layer. In this example, ‘Roads’ is used.
  2. Replace <field_name> with the name of the field containing the field values. In this example, ‘Status’ is used.
  3. Replace <field_value> with the value of the line features required for the calculation. In this example, ‘Good’ is used.
  1. Click Done.
The editor window with an example of the expression.
  1. In the Pop-ups pane, click Fields list and click Select fields.
  2. In the Select fields pane, under Expressions, click the expression created in Step 5 to display in the pop-up.

The image below displays the total length of good roads in the neighborhood in the pop-up in ArcGIS Online.

The Pop-up in web map displaying the total length of good roads when selecting the neighborhood feature layer.

Article ID: 000032389

Software:
  • ArcGIS Online

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