knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(itcfuns)
library(tidyverse)

Data frame with the plot center coordinates

plot_coords <- read_csv(system.file("extdata/plot_coords.csv", package = "itcfuns"))

plot_coords

Data frame with stem mapped trees in polar coordinates

stem_mapped_polar <- read_csv(system.file("extdata/stem_mapped_polar.csv", package = "itcfuns"))

stem_mapped_polar

Join plot center coordinates

stem_mapped_polar <- inner_join(stem_mapped_polar, plot_coords, by = c("plotID" = "PlotID"))

Convert to XY coordinates

stem_mapped_XY <- stem_mapped_polar %>%
  mutate(polar_to_XY(Azimuth, Distance, XPLOT, YPLOT, CrownOffsetAzimuth, CrownOffsetDistance, crs = 26910))

Trees detected for with ITC algorithm

detected_trees <- read_csv(system.file("extdata/detected_trees.csv", package = "itcfuns"))

detected_trees

Automatic tree matching

# Clean mapped_trees data frame
mapped_trees <- stem_mapped_XY %>%
  select(!c(XPLOT, YPLOT, Azimuth:CrownOffsetDistance)) %>%
  relocate(Z, SpeciesAbbrev, .after = Y)

detected_trees

nn_trees <- match_nn_trees(mapped_trees = mapped_trees, 
                           detected_trees = detected_trees, 
                           distance_type = "3D")

nn_trees


mqueinnec/itcfuns documentation built on March 31, 2024, 1:57 p.m.