HOW TO
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.
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, "<featureName1>"), FeaturesetByName($datastore, "<featureName2>"), FeaturesetByName($datastore, "<featureName3>), ]
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.<fieldName> } } if(end_id == null) { var candidate = First(Intersects(end_point, intersecting_points)) if(candidate != null) { end_id = candidate.<fieldName> } } }
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}} }
The image below demonstrates the start and end fields are populated with the point ID in the line feature class using an attribute rule.
Article ID:000030240
Get help from ArcGIS experts
Download the Esri Support App