Arcade intersection

1600
8
Jump to solution
11-04-2022 06:33 AM
MikeZuege
New Contributor II

I would like to know if it is possible to use the intersection function on a polygon and line.  An example would be to create a new geometry based on the road centerlines that fall within an urbanized boundary.  I have not come across any examples and everything I try, does not work.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

You can use this expression as Attribute Rule (triggers on Insert & Update) or in a popup:

// load the line fc
var lines = FeaturesetByName($datastore, "TestLines")
// get all intersecting lines
var i_lines = Intersects($feature, lines)
// for each intersecting line, get the length of the intersection, accumulate
var total = 0
for(var line in i_lines) {
    total += Length(Intersection(line, $feature))
}
return total

 

JohannesLindner_0-1667890197533.png

 


Have a great day!
Johannes

View solution in original post

8 Replies
jcarlson
MVP Esteemed Contributor

Can you share what you've tried? And what it is you're trying to accomplish? Intersecting features like you describe is absolutely possible in Arcade, but bringing those intersected features back to a map to actually visualize them (what I assume you mean by "create a new geometry") is not.

- Josh Carlson
Kendall County GIS
0 Kudos
JohannesLindner
MVP Frequent Contributor

Take a look at Intersection().

For example:

Calculate a field in the line feature class:

var polygons = FeaturesetByName($datastore, "TestPolygons")
var polygon = First(Intersects(polygons, $feature))
if(polygon == null) { return null }
var i_line = Intersection(polygon, $feature)
return Length(i_line)

 

Label the line with this expression

`line: ${Round(Length($feature))} meters\nintersection: ${Round($feature.DoubleField)} meters`

 

Result:

JohannesLindner_0-1667570466338.png

 


Have a great day!
Johannes
MikeZuege
New Contributor II

Thanks for the help.  Ultimately, what I am looking for is to be able to modify the boundary shape (urbanized area poly) and return the sum of each of the functionally classified road lengths. 

0 Kudos
jcarlson
MVP Esteemed Contributor

Is this a field calculation? A popup? An attribute rule?

- Josh Carlson
Kendall County GIS
0 Kudos
MikeZuege
New Contributor II

Thanks so much!  What I am trying to do, is to create a popup for the box and have it populate the total length of the lines that run through the box.

MikeZuege_0-1667837505244.png

 

0 Kudos
JohannesLindner
MVP Frequent Contributor

You can use this expression as Attribute Rule (triggers on Insert & Update) or in a popup:

// load the line fc
var lines = FeaturesetByName($datastore, "TestLines")
// get all intersecting lines
var i_lines = Intersects($feature, lines)
// for each intersecting line, get the length of the intersection, accumulate
var total = 0
for(var line in i_lines) {
    total += Length(Intersection(line, $feature))
}
return total

 

JohannesLindner_0-1667890197533.png

 


Have a great day!
Johannes
JohannesLindner
MVP Frequent Contributor

Depending on the length of your lines, you might want to use LengthGeodetic() instead of Length() to account for Earth's curvature.


Have a great day!
Johannes
0 Kudos
MikeZuege
New Contributor II

Thank You Johannes!

 

0 Kudos