#' Calculates and aggregates parameters on dendrometry of trees
#'
#' This function calculates additional variables and makes aggregations of
#' individual tree measures on the levels of
#' \itemize{
#' \item plot and year
#' \item plot, tree species and year
#' \item diameter class, plot and year
#' \item diameter class, plot, tree species and year
#' }
#' and it makes aggregations of volume data on logs on the levels of
#' \itemize{
#' \item decay stage, plot and year
#' \item decay stage, plot, tree species and year
#' }
#'
#' @param data_dendro dataframe on tree measures with variables `plot_id`,
#' `plottype`, `tree_measure_id`, `date_dendro`, `dbh_mm`, `height_m`,
#' `species`, `alive_dead`, `decaystage`, `period`, `old_id`, `year`,
#' `subcircle`, `plotarea_ha`,...
#' (output of function `load_data_dendrometry()`)
#' @param data_shoots dataframe on shoots as given from the function
#' `load_data_shoots()`
#' @param data_deadwood dataframe on logs with variables `plot_id`, `plottype`,
#' `date_dendro`, `species`, `decaystage`, `calc_volume_m3`, `period` and `year`
#' (output of function `load_data_deadwood()`)
#' @param height_model dataframe with `model` containing 'exp' or 'ln',
#' coefficients `P1` and `P2` to calculate height model for each combination of
#' `species`, `forest_reserve`, `period` and `plottype`. Height models in .xlsx
#' generated by `Fieldmap` can be grouped in a dataframe using function
#' `load_height_models()`
#' @param plotinfo dataframe on surveyed plots with variables `plot_id`,
#' `plottype`, `forest_reserve`, `survey_trees`, `survey_deadw`, `period` and
#' `year_dendro`
#' (output of function `load_plotinfo()`)
#'
#' @return List of dataframes that are mentioned in the above description
#'
#' @examples
#' library(forrescalc)
#' # (add path to your own fieldmap database here)
#' path_to_fieldmapdb <-
#' system.file("example/database/mdb_bosres.sqlite", package = "forrescalc")
#'
#' data_dendro <- load_data_dendrometry(path_to_fieldmapdb)
#' data_deadwood <- load_data_deadwood(path_to_fieldmapdb)
#' data_shoots <- load_data_shoots(path_to_fieldmapdb)
#' # omit argument 'example_dataset = TRUE' below to use all height models
#' height_model <- load_height_models(example_dataset = TRUE)
#' plotinfo <- load_plotinfo(path_to_fieldmapdb)
#' calculate_dendrometry(
#' data_dendro, data_deadwood, data_shoots, height_model, plotinfo)
#'
#' @export
#'
calculate_dendrometry <- function(data_dendro, data_deadwood, data_shoots,
height_model, plotinfo) {
data_stems <- compose_stem_data(data_dendro, data_shoots)
data_stems_calc <- calc_variables_stem_level(data_stems, height_model)
data_dendro_calc <- calc_variables_tree_level(data_dendro, data_stems_calc)
data_deadwood <- calc_intact_deadwood(data_deadwood)
by_plot <- calc_dendro_plot(data_dendro_calc, data_deadwood, plotinfo)
by_plot_species <-
calc_dendro_plot_species(data_dendro_calc, data_deadwood, plotinfo)
by_decay_plot <-
calc_deadw_decay_plot(plotinfo, data_deadwood, data_dendro_calc)
by_decay_plot_species <-
calc_deadw_decay_plot_species(plotinfo, data_deadwood, data_dendro_calc)
by_diam_plot <- calc_diam_plot(data_stems_calc, data_deadwood, plotinfo)
by_diam_plot_species <-
calc_diam_plot_species(data_stems_calc, data_deadwood, plotinfo)
return(
list(
dendro_by_plot = by_plot,
dendro_by_plot_species = by_plot_species,
dendro_by_diam_plot = by_diam_plot,
dendro_by_diam_plot_species = by_diam_plot_species,
deadw_by_decay_plot = by_decay_plot,
deadw_by_decay_plot_species = by_decay_plot_species
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.