Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

wkt_unnest

Flatten nested geometry structures


Description

Flatten nested geometry structures

Usage

wkt_unnest(wkt, keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

wkb_unnest(wkb, keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

Arguments

wkt

A character vector containing well-known text.

keep_empty

If TRUE, a GEOMETRYCOLLECTION EMPTY is left as-is rather than collapsing to length 0.

keep_multi

If TRUE, MULTI* geometries are not expanded to sub-features.

max_depth

The maximum recursive GEOMETRYCOLLECTION depth to unnest.

wkb

A list() of raw() vectors, such as that returned by sf::st_as_binary().

Value

An unclassed vector with attribute lengths, which is an integer vector with the same length as the input denoting the length to which each feature was expanded.

Examples

wkt_unnest("GEOMETRYCOLLECTION (POINT (1 2), POINT (3 4))")
wkt_unnest("GEOMETRYCOLLECTION EMPTY")
wkt_unnest("GEOMETRYCOLLECTION EMPTY", keep_empty = TRUE)

wkutils

Utilities for Well-Known Geometry Vectors

v0.1.1
MIT + file LICENSE
Authors
Dewey Dunnington [aut, cre] (<https://orcid.org/0000-0002-9415-4582>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.