Attribute Rule to Transfer Line to Point Fields using Arcade

212
3
Jump to solution
04-11-2024 06:45 AM
Labels (3)
AnnaPultro
New Contributor II

Hi there,

In the process of trying to return field from line geometry inside of attribute rule for point geometry. For visual reference I want to return the Max Downstream Invert value of the two highlighted lines (mains) intersecting with the point (manhole) to the point feature, ignoring the third main that intersects at starting vertex instead of the end. 

AnnaPultro_1-1712842654697.png

I am able to collect data from a point, populate line geometry with that information, and use Geometry functions to call which end is intersecting with the point. Has anyone had success doing the reverse or have thoughts on how to call geometry path of a line within point features?

Arcade Expression for gathering point data within Line Feature (this works!)

var g = Geometry($feature);
var fromPointGeometry = g.paths[-1][-1];
var ManholeRim = FeatureSetByName($datastore, "SewerDevice", ["RIMELEVATION"], false);
var fromPoint = First(Intersects(ManholeRim, fromPointGeometry ))
if (fromPoint == null) return
return fromPoint.RIMELEVATION - $feature.DEPTHDOWNSTREAM

Arcade Expression for gathering end vertex line data within Point Feature (pulls a number but is not correct since there is no argument that specifies which part of the line to pull data from)

var g = Geometry($feature)
var highpipeelev = FeatureSetByName($datastore, "SewerLine", ["DOWNSTREAMINVERT"], true)
var fromline = First(Intersects(highpipeelev, g))
var max_elev = Max(highpipeelev, "DOWNSTREAMINVERT")
if (fromline != null)
return max_elev

When attempting to call .paths for line geometry, I am getting an error stating unexpected null (on the var gg line)

var g = Geometry($feature)
var highpipeelev = FeatureSetByName($datastore, "SewerLine", ["DOWNSTREAMINVERT"], true)
var gg = Geometry(highpipeelev).paths[-1][-1]
var fromline = First(Intersects(highpipeelev, g))
var max_elev = Max(highpipeelev, "DOWNSTREAMINVERT")
if (fromline != null)
return max_elev

Same question asked on a different platform here without any response atm

arcade - Attribute Rules for ArcGIS Pro to transfer attribute from Line to Point - Geographic Inform...


 Updating Media

Arcade error for line geometry paths variable

0 Kudos
1 Solution

Accepted Solutions
AnnaPultro
New Contributor II

Thank you for the input, wanted to update this is what is working for me!

// get all intersecting lines
var lines = FeaturesetByName($datastore, "Stormwater_Pipe")
var i_lines = Intersects(lines, $feature)

// loop thorugh those lines, return true if any end point intersects $feature
var values = Array(0)
for(var line in i_lines) {
    var end_point = Geometry(line).paths[-1][-1]
    if(Intersects(end_point, $feature)) {
            Push(values, line["Diameter"])
    }
}
return Max(values)

 

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

The variable highpipeelev is a FeatureSet, but Geometry requires a Feature.

var highpipeelev = First(FeatureSetByName($datastore, "SewerLine", ["DOWNSTREAMINVERT"], true));
AnnaPultro
New Contributor II

Thank you for the input, wanted to update this is what is working for me!

// get all intersecting lines
var lines = FeaturesetByName($datastore, "Stormwater_Pipe")
var i_lines = Intersects(lines, $feature)

// loop thorugh those lines, return true if any end point intersects $feature
var values = Array(0)
for(var line in i_lines) {
    var end_point = Geometry(line).paths[-1][-1]
    if(Intersects(end_point, $feature)) {
            Push(values, line["Diameter"])
    }
}
return Max(values)

 

0 Kudos
AnnaPultro
New Contributor II

Ahh thank you, this helps. I think I still need to make a few more adjustments for it to pull the data properly. I found this documentation about updating intersecting features that provides more guidance. When I'm able to implement it to function as asked, I'll post here to provide exact code that worked for me. https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/UpdateIntersecting...

0 Kudos