Summary
In ArcGIS Pro, calculating the total length of lines within a polygon is useful for spatial analysis of an area in a map.
In this article, an Arcade expression is used to calculate the total length of the active pipes within a factory 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 pipes within the factory.
Procedure
- Open the ArcGIS Pro project.
- Right-click the polygon layer in the Contents pane and click Configure Pop-ups to open the Configure Pop-ups pane.
- Click Expressions to create an Arcade expression to use in the pop-up.
- In the Expressions pane, click New to add an expression.
- In the Expression Builder dialog box, specify a title to provide a name for the pop-up. In this example, the title is ‘Length of active pipes'.
- In the Expression section, specify the Arcade expression.
Length(Contains($feature, Filter(FeaturesetByName($datastore, '<feature_name>', ['*']), "<field_name> = '<field_value>'")))
- Replace <feature_name> with the name of the line layer. In this example, ‘Pipes’ is used.
- Replace <field_name> with the name of the field containing the field values. In this example, ‘Status’ is used.
- Replace <field_value> with the value of the line features required for the calculation. In this example, ‘In service’ is used.
- Click OK.
- In the Configure Pop-ups pane, select the Fields element. Click the Edit pop-up element
button to open the Field Options pane. - Specify a title or a caption and uncheck the Only use visible fields and Arcade expressions check box. In this example, the title is ‘Total length of active pipes in the factory’.
- Check the newly created field with the Arcade expression check box to display the total length of lines within the polygon.
- Click Back to apply the changes.
The image below displays the total length of active pipes in the factory in the pop-up in ArcGIS Pro.