Skip to contents

Expands geometries into a list of vectors of their components.

Usage

expand_geoms(x)

Arguments

x

an object of class rsgeo

Value

A list of rsgeo vectors containing each original geometry's components as a new vector.

Details

  • rs_MULTIPOINT expands into a vector of points

  • rs_LINESTRING expands into a vector points

  • rs_MULTILINESTRING expands into a vector of linestrings

  • rs_POLYGON expands into a vector of linestrings

  • rs_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.651673766085878, y: 0.4935413070488721 }))  
#> [2] Point(Coord { x: 0.3823879570700228, y: 0.10794362588785589 }))
#> 
#> [[2]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.9347052311059088, y: 0.48208011547103524 }))
#> [2] Point(Coord { x: 0.3861140925437212, y: 0.6684667381923646 })) 
#> 
#> [[3]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.12555509596131742, y: 0.1862176014110446 }))
#> [2] Point(Coord { x: 0.86969084572047, y: 0.723710946040228 }))    
#> 
#> [[4]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.21214252128265798, y: 0.5995658254250884 })) 
#> [2] Point(Coord { x: 0.013390333158895373, y: 0.7942398607265204 }))
#> 
#> [[5]]
#> <rs_POINT[2]>
#> [1] Point(Coord { x: 0.26722066872753203, y: 0.8273733186069876 }))
#> [2] Point(Coord { x: 0.3403489966876805, y: 0.4112744296435267 })) 
#>