Unnest recursive geometry structures

geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

# S3 method for default
geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

# S3 method for wk_wkt
geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

# S3 method for wk_wkb
geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

# S3 method for wk_wksxp
geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

# S3 method for data.frame
geo_unnest(x, ..., keep_empty = FALSE, keep_multi = TRUE, max_depth = 1)

Arguments

x

A geometry-like object, or one that can be coerced to a geometry-like object using as_geovctr().

...

Unused

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.

Examples

geo_unnest("GEOMETRYCOLLECTION (POINT (1 2), POINT (3 4))")
#> <wk_wkt[2]> #> [1] POINT (1 2) POINT (3 4)
geo_unnest("GEOMETRYCOLLECTION EMPTY")
#> <wk_wkt[0]>
geo_unnest("GEOMETRYCOLLECTION EMPTY", keep_empty = TRUE)
#> <wk_wkt[1]> #> [1] GEOMETRYCOLLECTION EMPTY
geo_unnest(geo_example_wkt, keep_multi = TRUE)
#> <wk_wkt[18]> #> [1] <NA> #> [2] POINT (30 10) #> [3] POINT EMPTY #> [4] POINT Z (1 1 5) #> [5] MULTIPOINT ((10 40), (40 30), (20 20... #> [6] MULTIPOINT EMPTY #> [7] POLYGON ((30 10, 40 40, 20 40... #> [8] POLYGON ((35 10, 45 45, 15 40... #> [9] POLYGON EMPTY #> [10] MULTIPOINT ((10 40), (40 30), (20 20... #> [11] MULTILINESTRING ((10 10, 20 20, 10 40... #> [12] MULTILINESTRING EMPTY #> [13] MULTIPOLYGON (((30 20, 45 40, 10 40... #> [14] MULTIPOLYGON (((40 40, 20 45, 45 30... #> [15] MULTIPOLYGON EMPTY #> [16] POINT (40 10) #> [17] LINESTRING (10 10, 20 20, 10 40... #> [18] POLYGON ((40 40, 20 45, 45 30...
geo_unnest(geo_example_wkt, keep_multi = FALSE)
#> <wk_wkt[24]> #> [1] <NA> POINT (30 10) #> [3] POINT EMPTY POINT Z (1 1 5) #> [5] POINT (10 40) POINT (40 30) #> [7] POINT (20 20) POINT (30 10) #> [9] POLYGON ((30 10, 40 40, 20 40... POLYGON ((35 10, 45 45, 15 40... #> [11] POLYGON EMPTY POINT (10 40) #> [13] POINT (40 30) POINT (20 20) #> [15] POINT (30 10) LINESTRING (10 10, 20 20, 10 40... #> [17] LINESTRING (40 40, 30 30, 40 20... POLYGON ((30 20, 45 40, 10 40... #> [19] POLYGON ((15 5, 40 10, 10 20... POLYGON ((40 40, 20 45, 45 30... #> [21] POLYGON ((20 35, 10 30, 10 10... POINT (40 10) #> [23] LINESTRING (10 10, 20 20, 10 40... POLYGON ((40 40, 20 45, 45 30...