knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE )
Install the development version of allodb from GitHub:
# install.packages("pak") pak::pak("ropensci/allodb")
Prior to calculating tree biomass using allodb, users need to provide a table (i.e. dataframe) with DBH (cm), parsed species Latin names, and site(s) coordinates. In the following examples we use data from the Smithsonian Conservation Biology Institute, USA (SCBI) ForestGEO dynamics plot (1st census in 2008, trees from 1 hectare). Data can be requested through the ForestGEO portal (https://forestgeo.si.edu/)
require(allodb) data(scbi_stem1) str(scbi_stem1)
allodb
provides a dataframe containing r nrow(allodb::equations)
parsed allometric equations.
data(equations)
Additional information about the equation table can be found in the equation metadata.
data(equations_metadata)
This equation table is the default in all functions of the package. Users can modify the set of equations that will be used to estimate biomass using the new_equations()
function: users can work on a subset of those equations, or add new equations to the table (see ?allodb::new_equations
). The customized equation table should be provided as an argument in the get_biomass()
(or other) function (argument name: new_eqtable
).
show_cols <- c("equation_id", "equation_taxa", "equation_allometry") eq_tab_acer <- new_equations(subset_taxa = "Acer") head(eq_tab_acer[, show_cols])
eq_tab_add <- new_equations( new_taxa = c("Quercus ilex", "Castanea sativa"), new_allometry = c("0.12*dbh^2.5", "0.15*dbh^2.7"), new_coords = c(4, 44), new_min_dbh = c(5, 10), new_max_dbh = c(35, 68), new_sample_size = c(143, 62) ) ## show added equations - they contain "new" in their equation_id head(eq_tab_add[grepl("new", eq_tab_add$equation_id), ])
The aboveground biomass (AGB) can be estimated using the get_biomass()
function: the required arguments are the diameter at breast height (DBH, in cm), the taxonomic identification (to the genus or species level), and the location (long-lat coordinates). The output is the aboveground biomass of the tree in kg.
get_biomass( dbh = 50, genus = "liriodendron", species = "tulipifera", coords = c(-78.2, 38.9) )
The get_biomass()
function can also be used to estimate the AGB of all trees in one (or several) censuses.
scbi_stem1$agb <- get_biomass( dbh = scbi_stem1$dbh, genus = scbi_stem1$genus, species = scbi_stem1$species, coords = c(-78.2, 38.9) )
plot( x = scbi_stem1$dbh, y = scbi_stem1$agb, col = factor(scbi_stem1$genus), xlab = "DBH (cm)", ylab = "AGB (kg)" )
Within the get_biomass()
function, new allometric equations are calibrated for each taxon/location combinations in the user-provided dataframe. This is done by attributing a weight to each equation in the equation table, based on its sampling size, and taxonomic and climatic similarity with the taxon/location combination considered.
allom_weights <- weight_allom( genus = "Acer", species = "rubrum", coords = c(-78, 38) ) ## visualize weights equ_tab_acer <- new_equations() equ_tab_acer$weights <- allom_weights keep_cols <- c( "equation_id", "equation_taxa", "sample_size", "weights" ) order_weights <- order(equ_tab_acer$weights, decreasing = TRUE) equ_tab_acer <- equ_tab_acer[order_weights, keep_cols] head(equ_tab_acer)
Equations are then resampled within their original DBH range: the number of resampled values for each equation is proportional to its weight (as attributed by the weight_allom()
function).
df_resample <- resample_agb( genus = "Acer", species = "rubrum", coords = c(-78, 38), nres = 1e4 ) plot( df_resample$dbh, df_resample$agb, xlab = "DBH (cm)", ylab = "Resampled AGB values (kg)" )
The resampled values are then used to fit the following nonlinear model: $AGB = a \cdot dbh ^ b + e$, with i.i.d. $e \sim \mathcal{N}(0, sigma^2)$. The parameters (a, b, and sigma) are returned by the est_params()
function. In other words, this function calibrates new allometric equations from sampling previous ones. New allometric equations are calibrated for each species and location by resampling the original compiled equations; equations with a larger sample size, and/or higher taxonomic rank, and climatic similarity with the species and location in question are given a higher weight in this process.
pars_acer <- est_params( genus = "Acer", species = "rubrum", coords = c(-78, 38) ) plot( df_resample$dbh, df_resample$agb, xlab = "DBH (cm)", ylab = "Resampled AGB values (kg)" ) curve(pars_acer$a * x^pars_acer$b, add = TRUE, col = 2, lwd = 2 )
The est_params()
function can be used for all species/site combinations in the dataset at once.
params <- est_params( genus = scbi_stem1$genus, species = scbi_stem1$species, coords = c(-78.2, 38.9) ) head(params)
AGB is then recalculated as AGB = a * dbh^b
within the get_biomass()
function.
The recalibrated equation for one taxon/location combination can be easily visualized with the illustrate_allodb()
function, which returns a ggplot (see package ggplot2
) with all resampled values, and the top equations used displayed in the legend. The user can control the number of equations and equation information shown in the legend. The red dotted line is the recalibrated equation used in the get_biomass()
function.
illustrate_allodb( genus = "Acer", species = "rubrum", coords = c(-78, 38) )
illustrate_allodb( genus = "Acer", species = "rubrum", coords = c(-78, 38), neq = 15, eqinfo = c("equation_taxa", "geographic_area") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.