# NOT RUN {
library(tibble)
library(sfheaders)
library(ggplot2)
# Example square region to be buffered (as sf object)
region <- tibble(
x = c(0, 0, 1, 1),
y = c(0, 1, 1, 0)
) %>%
sf_polygon()
# Size of buffer
size <- 0.05
# Compute "inwards" buffer
inwards_buffer_region <- region %>%
compute_buffer_region(direction = "in", size = size)
# Compute "outwards" buffer
outwards_buffer_region <- region %>%
compute_buffer_region(direction = "out", size = size)
# Plot all three regions:
ggplot() +
geom_sf(data = outwards_buffer_region, col = "blue", fill = "transparent") +
geom_sf(data = region, fill = "transparent") +
geom_sf(data = inwards_buffer_region, col = "orange", fill = "transparent") +
labs(title = "Regions: original (black), inwards buffer (orange), and outwards buffer (blue)")
# }
Run the code above in your browser using DataLab