Pull data from sewer line feature to manhole point feature

988
6
Jump to solution
07-30-2021 07:37 AM
Labels (1)
RobertThomsonErase
New Contributor II

I'm probably in the wrong group but I found something similar to my problem here:

Update Attribute of Intersecting from Point of Var... - Esri Community

I need to calculate the rough depth of a manhole. I can do this by pulling the upstream elevation of an attached pipe and subtracting it from the rim elevation of the manhole.

I have this example that pulls data from a point feature to a line feature and it works for me:

var g = Geometry($feature);
var fromPointGeometry = g.paths[0][0];
var fsPoint =FeatureSetByName($datastore, "ssInlet", ["FACILITYID"], false);
var fromPoint = First(Intersects(fsPoint, fromPointGeometry ) )
if (fromPoint == null) return
return fromPoint.FACILITYID;

So I tried this just to pull in a value which I can later subtract from the rim elevation.

var g = Geometry($feature);
var fromPointGeometry = g.paths[0][0];
var fsPoint =FeatureSetByName($datastore, "ssGravityMain", ["UPELEV"], false);
var fromPoint = First(Intersects(fsPoint, fromPointGeometry ) )
if (fromPoint == null) return
return fromPoint.UPELEV;

but it throws an error:  

Error 2717 Invalid Arcade expression, arcade error: Field not found script line 2

I'm not very familiar with Arcade, could someone point out what I need to make this work?

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

The error is in this line:

var fromPointGeometry = g.paths[0][0];

 

What this does is take the first point of the first segment of a line feature. It works in the first expression, because you run it on a line feature. It doesn't work in the second expression, because you run it on a point feature and those don't have the path variable.

This should work:

var g = Geometry($feature)
var fsLine = FeatureSetByName($datastore, "ssGravityMain", ["UPELEV"], true)
var fromLine = First(Intersects(fsLine , g))
if (fromLine == null) { return }
return $feature.RIMELEV - fromLine.UPELEV

Have a great day!
Johannes

View solution in original post

6 Replies
JohannesLindner
MVP Frequent Contributor

The error is in this line:

var fromPointGeometry = g.paths[0][0];

 

What this does is take the first point of the first segment of a line feature. It works in the first expression, because you run it on a line feature. It doesn't work in the second expression, because you run it on a point feature and those don't have the path variable.

This should work:

var g = Geometry($feature)
var fsLine = FeatureSetByName($datastore, "ssGravityMain", ["UPELEV"], true)
var fromLine = First(Intersects(fsLine , g))
if (fromLine == null) { return }
return $feature.RIMELEV - fromLine.UPELEV

Have a great day!
Johannes
RobertThomsonErase
New Contributor II

As it works now sometimes it picks the wrong value of UPELEV as there are two or more pipes attached to each MH (Possibly several in and one out).  

Is it possible to have the script look at each value of UPELEV for any line features of SSGravityMain that are connected to the MH (there could be 2 or more) and pick the smallest value which is the invert out?  

0 Kudos
JohannesLindner
MVP Frequent Contributor
var g = Geometry($feature)
var fsLine = FeatureSetByName($datastore, "ssGravityMain", ["UPELEV"], true)
var fromLines = Intersects(fsLine , g)
if (fromLines == null || Count(fromLines) == 0) { return }
return $feature.RIMELEV - Min(fromLines, "UPELEV")

Have a great day!
Johannes
AnnaPultro
New Contributor II

Hey Johannes, this is very helpful, I am trying to pull data only if the point intersects with the end vertex of the line. Currently with this code pulls values from all the lines intersecting the point. Do you know what code I can add to specify the end vertex only? This attribute rule is created within a point geometry feature class. Appreciate any insight you have on this! 

var g = Geometry($feature);
var sewer_mains = FeatureSetByName($datastore, "SewerLine", ["DOWNSTREAMINVERT"], true);
var connected_mains = Touches(sewer_mains, g);
if (connected_mains == null || Count(connected_mains) == 0) {return}
return Max(connected_mains, "DOWNSTREAMINVERT")
0 Kudos
RobertThomsonErase
New Contributor II

That's great and will certainly come in handy!

0 Kudos