Attribute Rule that allows a Spatial Join on Line Ending ONLY

534
4
Jump to solution
01-31-2022 01:33 PM
CHedger1227
New Contributor III

Hello,

I am looking for a very specific Attribute rule to be set up. I am not sure how this would be even set up. I am looking to create an Attribute Rule that will populate a GlobalID from one feature to another based on where the end of the line feature are snapped to one another. This is all taking place in the same feature class. Most of the lines are drawn in the same direction and I am looking to have it ONLY where the ENDS of the line are snapped to one another and then populate the linking GlobalID field on the other feature class. It has to be on the end only because the GlobalID's can only be in a certain direction.

Example 

Start of line: O

End of Line: X

O--------Line-1--------X----Line-2-----------O----------Line-3---------X

I am looking for where Line 1 and Line 2 meet NOT line 2 and Line 3

If you need further information please say so.

Thank you in advanced. 

Thank you
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Something like this?

// load the line fc
var lines = FeatureSetByName($datastore, "NameOfLineFC", ["GlobalID"], true)
// intersect with current line
var intersecting_lines = Intersects($feature, lines)
// we intersected $feature with itself, so we need to filter it out
var f_gid = $feature.GlobalID
intersecting_lines = Filter(intersecting_lines, "GlobalID <> @f_gid")

// loop through all intersecting lines
// return the GlobalID of the first line where the end point is the same as $feature's end point
var feature_end = Geometry($feature).paths[0][-1]
for(var line in intersecting_lines) {
  var line_end = Geometry(line).paths[0][-1]
  if(Intersects(feature_end, line_end)) {
    return line.GlobalID
  }
}
// if we land here, there is no line with intersecting end point
return null

Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

Something like this?

// load the line fc
var lines = FeatureSetByName($datastore, "NameOfLineFC", ["GlobalID"], true)
// intersect with current line
var intersecting_lines = Intersects($feature, lines)
// we intersected $feature with itself, so we need to filter it out
var f_gid = $feature.GlobalID
intersecting_lines = Filter(intersecting_lines, "GlobalID <> @f_gid")

// loop through all intersecting lines
// return the GlobalID of the first line where the end point is the same as $feature's end point
var feature_end = Geometry($feature).paths[0][-1]
for(var line in intersecting_lines) {
  var line_end = Geometry(line).paths[0][-1]
  if(Intersects(feature_end, line_end)) {
    return line.GlobalID
  }
}
// if we land here, there is no line with intersecting end point
return null

Have a great day!
Johannes
GdB_Admin
New Contributor III

@JohannesLindner  Can this be used to do a point to a line feature instead of a line feature to itself? would there be a big difference if I wanted to do this? 

Thank you for your time on this. Please let me know if you have any questions
0 Kudos
JohannesLindner
MVP Frequent Contributor
// load the point fc
var points = FeatureSetByName($datastore, "NameOfPointFC", ["GlobalID"], true)
// intersect with current line
var intersecting_points = Intersects($feature, points)

// loop through all intersecting points
// return the GlobalID of the first point that lies on the $feature's end point
var feature_end = Geometry($feature).paths[0][-1]
for(var p in intersecting_points) {
  if(Intersects(feature_end, p)) {
    return p.GlobalID
  }
}
// if we land here, there is no point on the $feature's end point
return null

Have a great day!
Johannes
GdB_Admin
New Contributor III

@JohannesLindner 

You are amazing thank you so much for taking the time to explain that to me

Thank you for your time on this. Please let me know if you have any questions
0 Kudos