Select to view content in your preferred language

Fill polyline ID field from ID field of a different point layer

842
3
01-23-2023 10:57 AM
ash-ym24
New Contributor

Hi Everyone, 

Basically, I have a network of polyline features that connect point features. Point features are labelled A1, A2 etc. Lines are named based on the 2 point features they connect: ID = A1A2. Is there a easy way to have the attribute ID of the polyline generate based on the 2 points it is snapped to?

 

Thanks in advance, 

A

0 Kudos
3 Replies
JohannesLindner
MVP Alum

Hey, welcome to the Community!

What product are you working with? ArcGIS Pro?

Is this a one-time operation or do you need that to calculate automatically?


Have a great day!
Johannes
0 Kudos
ash-ym24
New Contributor

Working with ArcGIS Pro. It is a repetitive  operation that I have been doing manually, and would like to be able to save a calculate field or other script to do. 

Thanks!

0 Kudos
JohannesLindner
MVP Alum

Arcade is your friend here.

 

// extract the line's start and end points
var start_point = Geometry($feature).paths[0][0]
var end_point = Geometry($feature).paths[-1][-1]

// load the point fc
var point_fc = FeaturesetByName($datastore, "TestPoints", ["TextField"], false)

// get the intersecting points' names
var i_start = First(Intersects(start_point, point_fc))
var i_end = First(Intersects(end_point, point_fc))
var names = [
    IIf(i_start == null, "", i_start.TextField),
    IIf(i_end == null, "", i_end.TextField),
    ]

// concatenate and return
return Concatenate(names, "")

 

 

Change the names of the point fc and the name field in lines 6, 12, and 13.

You can use this expression in the field calculator (switch to Arcade) or in an Attribute Rule.

 

JohannesLindner_0-1674503515532.png

 


Have a great day!
Johannes