Hello all,
I'm looking to get the address ranges along a street segment and populating it in the appropriate fields. The available field in the street segment are: SEG_ID (unique ID), FROMLEFT, TOLEFT, FROMRIGHT, TORIGHT.
The fields in the address feature class are: STNO (address number), SEG_ID (related segment from street centreline), SIDE_OF_RD (address location: left or right based on the side of the segment).
I've looked at the available attribute rules in the Address Solution from esri but the range calculation is based on the percentage along the segment which is not what we use to create the ranges. We determine the ranges based on the existing address numbers on the ground.
For example: the SEG_ID = 25000 for the street segment. For each address record, the SEG_ID is equal to 25000 because it's associated to that particular segment, STNO = 10, 12, 14 on the "Left" side of the road, and STNO = 15 on the "Right" side of the road.
It should return min. value of 10 and max. value of 14 where SIDE_OF_RD = "Left" and min. & max. value of 15 where SIDE_OF_RD = "Right". Then populate fields in street segment accordingly.
I was able to come up with the following code and it validates (ArcGIS Pro 2.9.5) but is returning null values where there are existing addresses. Any help would be appreciated! Thank you!
// Get Min Max Address Ranges on Left and Right side of segment
// get current segment id
var segid_field = $feature.SEG_ID
var fromleft_field = $feature.FROMLEFT
var toleft_field = $feature.TOLEFT
var fromright_field = $feature.FROMRIGHT
var toright_field = $feature.TORIGHT
// load address point and filter based on seg_id
var addr_fcs = Filter(FeaturesetByName($datastore, "Address_fc", ["STNO", "SEG_ID", "SIDE_OF_RD"], false), "SEG_ID = segid_field")
// loop through to get street no if address filter matches segid
if (!IsEmpty(addr_fcs) || addr_fcs != null) {
if ("SIDE_OF_RD" == "Left") {
// add STNO into Left address array
var left_addr = ["STNO"]
} else if ("SIDE_OF_RD" == "Right") {
// add STNO into Right address array
var right_addr = ["STNO"]
} else return;
}
// loop through STNO left array to get MAX and MIN
var fromleft_addr = MIN(left_addr)
var toleft_addr = MAX(left_addr)
var fromright_addr = MIN(right_addr)
var toright_addr = MAX(right_addr)
// return attributes into proper fields in centreline
return {
"result": {
"attributes":
Dictionary(fromleft_field, fromleft_addr,
toleft_field, toleft_addr,
fromright_field, fromright_addr,
toright_field, toright_addr
)
}
}
Solved! Go to Solution.
var seg = $feature.SEG_ID
var addr = Filter(FeaturesetByName($datastore, "Address_fc", ["STNO", "SEG_ID", "SIDE_OF_RD"], false), "SEG_ID = @seg")
var left_addr = Filter(addr, "SIDE_OF_RD = 'Left'")
var right_addr = Filter(addr, "SIDE_OF_RD = 'Right'")
return{
result: {attributes: {
FROMLEFT: Min(left_addr, "STNO"),
TOLEFT: Max(left_addr, "STNO"),
FROMRIGHT: Min(right_addr, "STNO"),
TORIGHT: Max(right_addr, "STNO"),
}}
}
var seg = $feature.SEG_ID
var addr = Filter(FeaturesetByName($datastore, "Address_fc", ["STNO", "SEG_ID", "SIDE_OF_RD"], false), "SEG_ID = @seg")
var left_addr = Filter(addr, "SIDE_OF_RD = 'Left'")
var right_addr = Filter(addr, "SIDE_OF_RD = 'Right'")
return{
result: {attributes: {
FROMLEFT: Min(left_addr, "STNO"),
TOLEFT: Max(left_addr, "STNO"),
FROMRIGHT: Min(right_addr, "STNO"),
TORIGHT: Max(right_addr, "STNO"),
}}
}
Thank you so much again @JohannesLindner! So simple. I over-thought the code. Just a minor typo with the extra '=' in lines 3 & 4. Not sure if that was a test for me to pick up on 😅.
var seg = $feature.SEG_ID
var addr = Filter(FeaturesetByName($datastore, "Address_fc", ["STNO", "SEG_ID", "SIDE_OF_RD"], false), "SEG_ID = @seg")
var left_addr = Filter(addr, "SIDE_OF_RD = 'Left'")
var right_addr = Filter(addr, "SIDE_OF_RD = 'Right'")
return{
result: {attributes: {
FROMLEFT: Min(left_addr, "STNO"),
TOLEFT: Max(left_addr, "STNO"),
FROMRIGHT: Min(right_addr, "STNO"),
TORIGHT: Max(right_addr, "STNO"),
}}
}
Good catch, but this site would be riddled with semi-correct answers if I did this on purpose 😅
It was probably a copy/paste issue, I fixed it. Glad you got it to work!