View source: R/st_erase_overlaps.R
st_erase_overlaps | R Documentation |
Erase overlapping geometries in a sf::sf()
object.
st_erase_overlaps(x, verbose = FALSE)
x |
|
verbose |
|
This is a more robust – albeit slower – implementation for
sf::st_difference()
when y
is missing.
sf::sf()
object.
sf::st_difference()
, wdpa_dissolve()
.
# create data
pl1 <- sf::st_polygon(list(matrix(c(0, 0, 2, 0, 1, 1, 0, 0), byrow = TRUE,
ncol = 2))) * 100
pl2 <- sf::st_polygon(list(matrix(c(0, 0.5, 2, 0.5, 1, 1.5, 0, 0.5),
byrow = TRUE, ncol = 2))) * 100
pl3 <- sf::st_polygon(list(matrix(c(0, 1.25, 2, 1.25, 1, 2.5, 0, 1.25),
byrow = TRUE, ncol = 2))) * 100
x <- sf::st_sf(order = c("A", "B", "C"),
geometry = sf::st_sfc(list(pl1, pl2, pl3), crs = 3395))
# erase overlaps
y <- st_erase_overlaps(x)
# plot data for visual comparison
par(mfrow = c(1, 2))
plot(sf::st_geometry(x), xlim = c(0, 200), ylim = c(0, 250),
main = "original", col = "transparent")
plot(sf::st_geometry(y), , xlim = c(0, 200), ylim = c(0, 250),
main = "no overlaps", col = "transparent")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.