Arcade: Script to retrieve the greater diameter between connecting pipes

249
2
01-07-2022 04:59 AM
Labels (1)
JustinBernard
New Contributor

Hello, 

 I wonder if the community can help me with some Arcade scripting for an attribute rule.

I have a network of pipes that are connected to nodes. Most of pipes connecting have the same pipe diameter, but there instances where two pipes connecting to a node will have different diameter(larger pipe connecting to a smaller pipe)

I have a column in the node table called "Maximum Pipe Diameter" and I would like to populate the column with the diameter values of the connecting pipes. As stated above, the majority of the connecting pipes will have the same diameter, but there are a number of nodes where the connecting pipes have different diameters. 

Can an attribute rule be made to populate the Maximum Pipe Diameter with the larger diameter value of the connecting pipe? I've been looking at Github and wasn't able to find suitable script to perform this task.

Thanks for your help!

Justin

0 Kudos
2 Replies
jcarlson
MVP Honored Contributor

I don't have a layer to test this against, but I assume this shouldn't be too hard. Are the pipes all coming from the same layer? How about something like this?

var n = $feature

var pipes = FeatureSetByPortalItem(
    Portal('your-url'),
    'itemid',
    0, // or whatever layer index
    ['pipe_diameter'],
    true
)

var xs_pipes = Intersects(pipes, n)

var diam = Max(xs_pipes, 'pipe_diameter')

return diam

 

- Josh Carlson
Kendall County GIS
0 Kudos
JustinBernard1886
New Contributor III

Hi Josh,
Yeah, the pipes all reside on one layer. I'll give  your code a shot. 
Thanks so much!
Justin

0 Kudos