Given a LineString or MultiLineString, expand the geometry into each and every component Line.
Details
A LineString
is composed of one or more Line
s. A Line is a connected
by a start and end coordinate only.
Examples
x <- geom_linestring(1:10, 10:1)
length(x)
#> [1] 1
explode_lines(x)
#> <rs_LINESTRING[9]>
#> [1] LineString([Coord { x: 1.0, y: 10.0 }, Coord { x: 2.0, y: 9.0 }]))
#> [2] LineString([Coord { x: 2.0, y: 9.0 }, Coord { x: 3.0, y: 8.0 }]))
#> [3] LineString([Coord { x: 3.0, y: 8.0 }, Coord { x: 4.0, y: 7.0 }]))
#> [4] LineString([Coord { x: 4.0, y: 7.0 }, Coord { x: 5.0, y: 6.0 }]))
#> [5] LineString([Coord { x: 5.0, y: 6.0 }, Coord { x: 6.0, y: 5.0 }]))
#> [6] LineString([Coord { x: 6.0, y: 5.0 }, Coord { x: 7.0, y: 4.0 }]))
#> [7] LineString([Coord { x: 7.0, y: 4.0 }, Coord { x: 8.0, y: 3.0 }]))
#> [8] LineString([Coord { x: 8.0, y: 3.0 }, Coord { x: 9.0, y: 2.0 }]))
#> [9] LineString([Coord { x: 9.0, y: 2.0 }, Coord { x: 10.0, y: 1.0 }]))