Arcade ExplodeSegments() function

874
6
03-21-2022 03:54 AM
Status: Closed
Labels (1)
Bud
by
Notable Contributor

Could an Arcade function be added that would explode geometries into separate lines for each segment?

That would be helpful when doing complex analysis on polyline segments.

Tags (1)
6 Comments
JohannesLindner
Bud
by

@JohannesLindner @Thanks, what I meant was: explode a given polyline part into multiple 2-vertex segments (split at each vertex).

DanPatterson

Split Line At Vertices (Data Management)—ArcGIS Pro | Documentation

but then you would be getting into Arcade having different license levels

JohannesLindner

I don't know... Seems like a quite narrow use case to make a function for. Plus, you can easily do it yourself:

function explode_polyline(geo) {
    var segments = []
    for(var p in geo.paths) {
        for(var q = 1; q < Count(geo.paths[p]); q++) {
            var point0 = paths[p][q-1]
            var point1 = paths[p][q]
            Push(segments, Polyline({"paths": [[point0, point1]], "spatialReference": geo.spatialReference}))
        }
    }
    return segments
}


Console(explode_polyline(Geometry($feature)))

 

Bud
by

@JohannesLindner Fair enough.

@KoryKramer, feel free to close. Cheers.

CraigWilliams
Status changed to: Closed

As noted, each segment can be obtained by looping through the vertices of the geometry.