Code
library(sf)
library(tmap)
library(dplyr)
library(ggplot2)
A map with polygons.
library(sf)
library(tmap)
library(dplyr)
library(ggplot2)
<- st_read("data/nz.gpkg") %>%
nz st_union() %>%
st_as_sf() %>%
mutate(What = "Land")
<- nz %>%
not_nz st_union() %>%
st_buffer(500) %>%
st_bbox() %>%
st_as_sfc() %>%
st_as_sf() %>%
st_difference(nz) %>%
mutate(What = "Water")
<- nz %>%
nz_not_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.
tmap
ggplot2