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.
Solved! Go to Solution.
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
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.
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:
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.
Is this a field calculation? A popup? An attribute rule?
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.
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
Depending on the length of your lines, you might want to use LengthGeodetic() instead of Length() to account for Earth's curvature.
Thank You Johannes!