Select to view content in your preferred language

Extracting Road Names for Beginning and End Locations

640
4
08-31-2022 11:31 AM
Labels (2)
ChrisSpadi
New Contributor III

Greetings,

I have a network of roads with street names. I created point features of beginning and end vertices of the lines to get the road names of intersecting roads. Then I spatial joined them back to the original dataset.

I tried using split function and it worked but in some cases (row 2) where the road names have a third or fourth name- this solution doesn't work.

What I would like is for the 2nd row to have:

BegLocation_New equal Chapala St

EndLocation_New equal State St 

ChrisSpadi_1-1661970014216.png

I was thinking I could wildcard query the field that has more than one '&' delimiter and remove text before it?

Looking for solution in python or arcade within the field calculator.

OR if there is a model or some script starting from scratch I am open to that as well. Have found some solutions but many are either out dated or don't specifically offer what I am looking for.

 

Thanks for any feedback or input. Best Regards. 

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

If there are more than two streets in the EndLocation attribute, how do you know which one to select? If it's always the second to last one, take the length - 2 array value of the split.

var string = 'Chapala St & Bath St & E Spring St & West St';
var arr = split(string, '&')
return arr[Count(arr)- 2]

 

0 Kudos
ChrisSpadi
New Contributor III

I don't think this will work because I am realizing the BegLocation and EndLocation have the intersecting street name but they vary in placement in the string base off the original fc beg and end vertices.

Work Example.png

 Is there a way to use the NAME_ALF field to remove it from the BegLocation and EndLocation fields? That way the remaining string would in most cases be the intersection road names?

0 Kudos
KenBuja
MVP Esteemed Contributor

You can cycle through the Split array items and discard the ones that equal the NAME_ALF value. The next problem would be picking the right one for your second row in this example. Why would it be State and not E Anapamu?

var street = 'Bath St';
var string = 'Chapala St & Bath St';
var arr = split(string, '&')
var output
for (var i in arr) {
    if (Trim(arr[i]) != street) return Trim(arr[i])
}
0 Kudos
ChrisSpadi
New Contributor III

That happened when I deleted identicals, where streets turn from E to W or S to N. It left those in. 

0 Kudos