Expands geometries into a list of vectors of their components.
Details
rs_MULTIPOINT
expands into a vector of pointsrs_LINESTRING
expands into a vector pointsrs_MULTILINESTRING
expands into a vector of linestringsrs_POLYGON
expands into a vector of linestringsrs_MULTIPOLYGON
expands into a vector of polygons
If you wish to have a single vector returned, pass the results
into flatten_geoms()
.
Examples
mpnts <- geom_multipoint(runif(10), runif(10), rep.int(1:5, 2))
expand_geoms(mpnts)
#> [[1]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.20597457489930093, y: 0.9347052311059088 }))
#> [2] Point(Coord { x: 0.49769924208521843, y: 0.3861140925437212 }))
#>
#> [[2]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.7698414199985564, y: 0.26722066872753203 }))
#> [2] Point(Coord { x: 0.7774452213197947, y: 0.3403489966876805 }))
#>
#> [[3]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.17655675252899528, y: 0.21214252128265798 }))
#> [2] Point(Coord { x: 0.7176185082644224, y: 0.013390333158895373 }))
#>
#> [[4]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.384103718213737, y: 0.12555509596131742 }))
#> [2] Point(Coord { x: 0.3800351794343442, y: 0.86969084572047 }))
#>
#> [[5]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.6870228466577828, y: 0.651673766085878 }))
#> [2] Point(Coord { x: 0.9919060948304832, y: 0.3823879570700228 }))
#>