Description Usage Arguments Value See Also Examples
View source: R/spatial_functions.R
Return all pairwise distances between two data frames of trees
1 | focal_vs_comp_distance(focal_trees, comp_trees)
|
focal_trees |
An |
comp_trees |
An |
A data frame with three columns: focal_ID
of focal tree,
comp_dist
of competitor tree, and dist
of distance between
them.
Other spatial functions:
add_buffer_variable()
,
compute_buffer_region()
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 | library(tibble)
library(ggplot2)
library(sf)
# Create toy example focal and competitor trees
focal_trees <- tibble(
focal_ID = c(1, 2, 3),
x = c(0.3, 0.6, 0.7),
y = c(0.1, 0.5, 0.7)
) %>%
st_as_sf(coords = c("x", "y"))
comp_trees <- tibble(
comp_ID = c(4, 5, 6, 7),
x = c(0, 0.2, 0.4, 0.6),
y = c(0.6, 0.7, 1, 0.2)
) %>%
st_as_sf(coords = c("x", "y"))
# Plot both sets of trees
ggplot() +
geom_sf_label(data = focal_trees, aes(label = focal_ID), col = "black") +
geom_sf_label(data = comp_trees, aes(label = comp_ID), col = "orange") +
labs(title = "Focal trees in black, competitor trees in orange")
# Compute corresponding distances between the 3 focal trees and 4 competitor trees
focal_vs_comp_distance(focal_trees, comp_trees)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.