st_union: Union geometries

Description Usage Arguments See Also Examples

View source: R/union.R

Description

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.

Usage

1
st_union(x, y, by_feature = TRUE)

Arguments

x

A geometry or a set of geometries of class sfc to be unioned.

y

(optional). A geometry or a set of geometries of class sfc.

by_feature

default is TRUE. Union each element of x with corresponding y element. If FALSE, all the features are first unioned row-wise, then all unioned together.

See Also

sf::st_union(), sf::st_combine()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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
summarise(geom, union = st_union(origin, destin, by_feature = FALSE))

etiennebr/geotidy documentation built on Feb. 28, 2020, 4:45 a.m.