compute_buffer_region {forestecology}R Documentation

Compute buffer to a region.

Description

Compute buffer to a region.

Usage

compute_buffer_region(region, direction = "in", size)

Arguments

region

An sf polygon object of region to be buffered

direction

"in" for buffers that are contained within region (default), "out" for buffers that contain region.

size

Distance to determine which neighboring trees to a focal tree are competitors. The units are assumed to be the same as the geometry variables in growth_df.

Value

An sf polygon object of buffer

See Also

Other spatial functions: add_buffer_variable(), focal_vs_comp_distance()

Examples

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)")

[Package forestecology version 0.2.0 Index]