Select to view content in your preferred language

can Arcade be used to populate centreline To/From values

695
2
Jump to solution
06-09-2022 11:17 AM
SarahHartholt
Frequent Contributor

I would like to use modelbuilder and/or field calculator with arcade to extract To/From values at road intersections. I have 2 feature classes. A road centreline layer that is broken up at intersections and I used the Intersect tool to create points at each of the intersections containing the road names. How can I perform the following:

- iterate through the road centreline layer

- select points that intersect with each centreline

- for each point that has a Road_Name that is not the same as the centreline Road_Name, append each to the ToFrom field delimited by a comma (,)

 

For example, in my screen capture I would like the To/From field for my Wellington Main St. centreline to display MARY AVENUE , SKIFF COVE ROAD 

SarahHartholt_0-1654798639760.png

 

 

1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Arcade is perfect for that.

 

// load the points
var points = FeatureSetByName($datastore, "Database.DataOwner.Intersection_Points", ["Road_Name"], true)

// get all points intersecting the current centreline
var points_on_feature = Intersects($feature, points)

// filter out all points that belong to this centreline
var road_name = $feature.Road_Name
var points_of_other_streets = Filter(points_on_feature, "Road_Name <> @road_name")

// maybe you want to sort?
points_of_other_streets = OrderBy(points_of_other_streets , "Road_Name")

// iterate through all remaining points and extract the road name
var road_names = []
for(var p in points_of_other_streets) {
    Push(road_names, p.Road_Name)
}

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

 

 

You can use that expression in the Calculate Field tool. Or, to make it automatic, you could create a Calculation Attribute Rule that calculates the value each time you create (and/or update) a centreline.


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

Arcade is perfect for that.

 

// load the points
var points = FeatureSetByName($datastore, "Database.DataOwner.Intersection_Points", ["Road_Name"], true)

// get all points intersecting the current centreline
var points_on_feature = Intersects($feature, points)

// filter out all points that belong to this centreline
var road_name = $feature.Road_Name
var points_of_other_streets = Filter(points_on_feature, "Road_Name <> @road_name")

// maybe you want to sort?
points_of_other_streets = OrderBy(points_of_other_streets , "Road_Name")

// iterate through all remaining points and extract the road name
var road_names = []
for(var p in points_of_other_streets) {
    Push(road_names, p.Road_Name)
}

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

 

 

You can use that expression in the Calculate Field tool. Or, to make it automatic, you could create a Calculation Attribute Rule that calculates the value each time you create (and/or update) a centreline.


Have a great day!
Johannes
SarahHartholt
Frequent Contributor

That worked perfectly, thank you! I just reworked the last couple lines to remove duplicated road names on dead end roads (i.e. a dead end road that intersects wellington main st. would have a value of WELLINGTON MAIN ST, WELLINGTON MAIN ST)

 

// remove repeating road names i.e. for dead end roads
var unique_name = Distinct(road_names)

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

 

0 Kudos