Access child geometries

geos_geometry_n(geom, n)

geos_ring_n(geom, n)

Arguments

geom

A GEOS geometry vector

n

The (one-based) index of the child geometry

Value

A GEOS geometry vector along the recycled length of geom and i.

Examples

multipoint <- "MULTIPOINT (0 0, 1 1, 2 2)"
geos_geometry_n(multipoint, seq_len(geos_num_geometries(multipoint)))
#> <geos_geometry[3]>
#> [1] <POINT (0 0)> <POINT (1 1)> <POINT (2 2)>

poly <- "POLYGON ((0 0, 0 1, 1 0, 0 0), (0.1 0.1, 0.1 0.2, 0.2 0.1, 0.1 0.1))"
geos_ring_n(poly, seq_len(geos_num_rings(poly)))
#> <geos_geometry[2]>
#> [1] <LINEARRING (0 0, 0 1, 1 0, 0 0)>                
#> [2] <LINEARRING (0.1 0.1, 0.1 0.2, 0.2 0.1, 0.1 0.1)>