Code
library(sf)
library(tmap)
library(dplyr)
library(ggplot2)A map with polygons.
library(sf)
library(tmap)
library(dplyr)
library(ggplot2)nz <- st_read("data/nz.gpkg") %>%
st_union() %>%
st_as_sf() %>%
mutate(What = "Land")
not_nz <- nz %>%
st_union() %>%
st_buffer(500) %>%
st_bbox() %>%
st_as_sfc() %>%
st_as_sf() %>%
st_difference(nz) %>%
mutate(What = "Water")
nz_not_nz <- nz %>%
bind_rows(not_nz) %>%
mutate(What = as.factor(What))Perhaps unsurprisingly, this is the case where both packages require the least additional work to get the desired result.
tmapggplot2