Select to view content in your preferred language

# How to construct intersecting point between two lines with ArcGIS Arcade?

707
4
08-22-2023 08:51 AM
Occasional Contributor

I need to construct a point on the intersection of 2 lines. How can I do that with Arcade?

Intersects() basically return either a boolean or a feature that intersects, which is no good for my case.

Intersection() doesn't seem to be able to return a point geometry? In my case, Intersection() will return a feature with null geometry - assuming the geometry would need to be a polygon in this case?

Am I missing something really obvious here?

Thanks

Tags (2)
1 Solution

Accepted Solutions
Esri Regular Contributor

You're on the right path, Intersection() works when you're working with 2 individual geometries, whereas in your instance it's 1 geometry with a collection (even though your collection is only 1 intersecting geometry)

I suggest digging into the resulting intersects result using:

``````var intersectsResult = Intersects(\$feature, otherLayer);

if (Count(intersectsResult) == 1) {
// Run Intersection and the result will be the intersecting point geometry
var intersectingPoint = Intersection(\$feature, Geometry(First(intersectsResult )));
} else {
// There's more than 1 intersecting line, do nothing
return null;
}``````

If you do want to work with multiple intersecting lines, using a for loop() will allow you to cycle through the results and work with each intersecting point geometry like line 5.

4 Replies
by
Frequent Contributor
Occasional Contributor

@ArmstKP Thanks for your input, but none of these solutions really utilise Arcade. And I need to do it in Arcade.

by
MVP Esteemed Contributor

The only way I could come up with is to use the Cut function and get the last vertex of the first polyline in the first geometry in the returned array. This assumes that you have just one line and a simple cut. Otherwise, you'll have to go through the array to make sure you're getting the correct polyline.

Esri Regular Contributor

You're on the right path, Intersection() works when you're working with 2 individual geometries, whereas in your instance it's 1 geometry with a collection (even though your collection is only 1 intersecting geometry)

I suggest digging into the resulting intersects result using:

``````var intersectsResult = Intersects(\$feature, otherLayer);

if (Count(intersectsResult) == 1) {
// Run Intersection and the result will be the intersecting point geometry
var intersectingPoint = Intersection(\$feature, Geometry(First(intersectsResult )));
} else {
// There's more than 1 intersecting line, do nothing
return null;
}``````

If you do want to work with multiple intersecting lines, using a for loop() will allow you to cycle through the results and work with each intersecting point geometry like line 5.