Given a vector of geometries combine them into a single geometry.
Details
combine_geoms()
combine_geoms()
combines a vector of geometries into a vector of length one
their MULTI
counterpart.
rs_POINT
andrs_MULTIPOINT
->rs_MULTIPOINT
rs_LINESTRING
andrs_MULTILINESTRING
->rs_MULTILINESTRING
rs_POLYGON
andrs_MULTIPOLYGON
->rs_MULTIPOLYGON
rs_GEOMETRYCOLLECTION
is not supported
union_geoms()
union_geoms()
creates a union of all geometries removing repeated points
or dissolving shared boundaries.
rs_POINT
- combines and removes repeated pointsrs_MULTIPOINT
- combines removes repeated pointsrs_LINESTRING
- combines and removes duplicated pointsrs_MULTILINESTRING
- combines and removes duplicated pointsrs_POLYGON
- unions geometries into a single geometryrs_MULTIPOLYGON
- unions geometries into a single geometry
Examples
pnts <- geom_point(runif(10), runif(10))
combine_geoms(pnts)
#> <rs_POINT[1]>
#> [1] MultiPoint([Point(Coord { x: 0.6868990743532777, y: 0.009578507393598557 }...
lns <- geom_linestring(1:100, runif(100, -10, 10), rep.int(1:5, 20))
union_geoms(lns)
#> <rs_MULTILINESTRING[1]>
#> [1] MultiLineString([LineString([Coord { x: 1.0, y: 6.518315509893 }, Coord { ...
x <- c(0, 1, 1, 0, 0)
y <- c(0, 0, 1, 1, 0)
p1 <- geom_polygon(x, y)
p2 <- geom_polygon(x - 1, y + 0.5)
z <- c(p1, p2)
res <- union_geoms(z)
res
#> <rs_MULTIPOLYGON[1]>
#> [1] MultiPolygon([Polygon { exterior: LineString([Coord { x: 0.0, y: 0.5 }, Co...
if (rlang::is_installed(c("sf", "wk"))) {
plot(z)
plot(res, lty = 3, border = "blue", add = TRUE, lwd = 4)
}