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

483
4
Jump to solution
08-22-2023 08:51 AM
Woodpeckerus
New Contributor III

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)
0 Kudos
1 Solution

Accepted Solutions
CarmelConnolly
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.

View solution in original post

4 Replies
Woodpeckerus
New Contributor III

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

0 Kudos
KenBuja
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.

0 Kudos
CarmelConnolly
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.