Binary logical operations (1)

Partly based on vignette 3 from sf.

First create some objects to play with.

  • x: 3 touching polygons
  • y: 4 overlapping polygons
b0 <- st_polygon(list(rbind(c(-1, -1), c(1, -1), c(1, 1), c(-1, 1), c(-1, -1))))
b1 <- b0 + 2
b2 <- b0 + c(-0.2, 2)
x <- st_sfc(b0, b1, b2)
a0 <- b0 * 0.8
a1 <- a0 * 0.5 + c(2, 0.7)
a2 <- a0 + 1
a3 <- b0 * 0.5 + c(2, -0.5)
y <- st_sfc(a0, a1, a2, a3)
plot(x, border = 'red')
plot(y, border = 'green', add = TRUE)