Extract simple geometries

wk_flatten(handleable, ..., max_depth = 1)

wk_flatten_filter(handler, max_depth = 1L, add_details = FALSE)

Arguments

handleable

A geometry vector (e.g., wkb(), wkt(), xy(), rct(), or sf::st_sfc()) for which wk_handle() is defined.

...

Passed to the wk_handle() method.

max_depth

The maximum (outer) depth to remove.

handler

A wk_handler object.

add_details

Use TRUE to add a "wk_details" attribute, which contains columns feature_id, part_id, and ring_id.

Value

handleable transformed such that collections have been expanded and only simple geometries (point, linestring, polygon) remain.

Examples

wk_flatten(wkt("MULTIPOINT (1 1, 2 2, 3 3)"))
#> <wk_wkt[3]> #> [1] POINT (1 1) POINT (2 2) POINT (3 3)
wk_flatten( wkt("GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 1))))"), max_depth = 2 )
#> <wk_wkt[1]> #> [1] GEOMETRYCOLLECTION (POINT (0 1))