HOW TO

Auto-populate start and end fields of a line feature class connected to different points using an attribute rule in ArcGIS Pro

Last Published: April 27, 2023

Summary

When editing data, attribute rules in ArcGIS Pro are used to efficiently populate attributes on existing features. Sometimes, it is necessary to add start and end fields to a line feature class connected to different point feature classes for construction purposes, such as to connect pipelines to multiple sources.

This article describes the workflow to auto-populate start and end fields of a line feature class connected to different points containing assigned IDs using an attribute rule in ArcGIS Pro.

Procedure

  1. Open the ArcGIS Pro project.
  2. In the Catalog pane, browse to and right-click the line feature class, and click Manage.
  3. In the Feature Class Properties window, in the Manage section, check the Global IDs check box and click OK at the bottom right corner of the window.
Enable Global IDs
  1. Add two new text data type fields on the line feature layer to indicate the start and end point. In this example, 'Start_Point' and 'End_Point' are used to represent the start and end fields. Refer to ArcGIS Pro: Add Fields (multiple) (Data Management) for more information.
  2. Right-click the feature layer in the Contents pane and click Data Design > Attribute Rules.
  3. Click the Add Rule drop-down and select Add Immediate Calculation Rule.
  4. Specify a Rule Name. For this example, ‘New Rule’ is used.
  5. In the Expression box, type the following Arcade expression.
    1. Abort the update if the geometry has not changed.
if($editcontext.editType == "UPDATE") {
    var cur_geom = Geometry($feature)
    var prev_geom = Geometry($originalfeature)
    if(Equals(cur_geom, prev_geom)) { return }
}
  1. Load the point feature classes. In this example, three point feature classes are used.
var point_fcs = [
    FeaturesetByName($datastore, "<featureName1>"),
    FeaturesetByName($datastore, "<featureName2>"),
    FeaturesetByName($datastore, "<featureName3>),
]
  1. Get the start and end point of the line feature class.
var start_point = Geometry($feature).paths[0][0]
var end_point = Geometry($feature).paths[-1][-1]
  1. Find the IDs of the points intersecting the line's start and end point. Replace <fieldName> with the name of the point ID field.
var start_id = null
var end_id = null

for(var p in point_fcs) {
    
    var intersecting_points = Intersects($feature, point_fcs[p])

    if(start_id == null) {
        var candidate = First(Intersects(start_point, intersecting_points))
        if(candidate != null) { start_id = candidate.<fieldName> }
    }

    if(end_id == null) {
        var candidate = First(Intersects(end_point, intersecting_points))
        if(candidate != null) { end_id = candidate.<fieldName> }
    }
}
  1. Return the IDs of the start and end points.
return {
    result: {attributes: {Start_Point: start_id, End_Point: end_id}}
}

The code below shows the example of the full working script.

if($editcontext.editType == "UPDATE") {
    var cur_geom = Geometry($feature)
    var prev_geom = Geometry($originalfeature)
    if(Equals(cur_geom, prev_geom)) { return }
}

var point_fcs = [
    FeaturesetByName($datastore, "Point1"),
    FeaturesetByName($datastore, "Point2"),
    FeaturesetByName($datastore, "Point3"),
]

var start_point = Geometry($feature).paths[0][0]
var end_point = Geometry($feature).paths[-1][-1]

var start_id = null
var end_id = null

for(var p in point_fcs) {

    var intersecting_points = Intersects($feature, point_fcs[p])

    if(start_id == null) {
        var candidate = First(Intersects(start_point, intersecting_points))
        if(candidate != null) { start_id = candidate.PointID }
    }

    if(end_id == null) {
        var candidate = First(Intersects(end_point, intersecting_points))
        if(candidate != null) { end_id = candidate.PointID }
    }
}

return {
    result: {attributes: {Start_Point: start_id, End_Point: end_id}}
}
  1. Under the Triggers column, check the Insert and Update check box.
  2. On the Attribute Rules tab, in the Attribute Rules group, click Save.

The image below demonstrates the start and end fields are populated with the point ID in the line feature class using an attribute rule.

The start and end point fields are auto-populated

Article ID: 000030240

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 x

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