Description Usage Arguments Value See Also Examples
View source: R/spatial_functions.R
Compute buffer to a region.
1 | compute_buffer_region(region, direction = "in", size)
|
region |
An |
direction |
"in" for buffers that are contained within |
size |
Distance to determine which neighboring trees to a focal tree are
competitors. The units are assumed to be the same as the |
An sf
polygon object of buffer
Other spatial functions:
add_buffer_variable()
,
focal_vs_comp_distance()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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)")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.