compute_buffer_region: Compute buffer to a region.

Description Usage Arguments Value See Also Examples

View source: R/spatial_functions.R

Description

Compute buffer to a region.

Usage

1
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

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

forestecology documentation built on Oct. 2, 2021, 5:07 p.m.