st_union.Rd
Union geometries to create MULTI* geometries in the case of different
geometries. If geometries are identical, the union returns a single geometry.
If you need to preserve all geometries, use sf::st_combine()
. This function
behaves differently than sf
because it strictly returns 1 or length(x)
geometries.
st_union(x, y, by_feature = TRUE)
x | A geometry or a set of geometries of class |
---|---|
y | (optional). A geometry or a set of geometries of class |
by_feature | default is |
library(tibble) library(dplyr) geom <- tibble( x = 1:3, y = 4:6, origin = st_point(x, y), destin = st_point(x + 1, y + 1) ) geom <- mutate(geom, union = st_union(origin, destin)) geom#> # A tibble: 3 x 5 #> x y origin destin union #> <int> <int> <POINT> <POINT> <MULTIPOINT> #> 1 1 4 (1 4) (2 5) ((1 4), (2 5)) #> 2 2 5 (2 5) (3 6) ((2 5), (3 6)) #> 3 3 6 (3 6) (4 7) ((3 6), (4 7))#> # A tibble: 1 x 1 #> union #> <MULTIPOINT> #> 1 ((1 4), (2 5), (3 6), (4 7))