| Title: | Utility Functions for Forest Inventory and Silviculture |
|---|---|
| Description: | Perform common dendrometry operations such as inventory preparing, and inventory data analysis. |
| Authors: | Adrián Cidre González [aut, cre], Aitor Vázquez Veloso [aut] |
| Maintainer: | Adrián Cidre González <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.0 |
| Built: | 2026-06-20 11:23:21 UTC |
| Source: | https://github.com/cidree/silviculture |
Biomass models available in silviculture package. If you would like
to suggest new models, please open a new issue.
biomass_modelsbiomass_models
A tibble
Carbon content percentages per biomass component available in the
silviculture package, compiled from Díeguez-Aranda et al. (2009)
and Montero et al. (2005). If you would like to suggest new models, please
open a new issue.
carbon_modelscarbon_models
A tibble with 264 rows and 13 variables:
Character. Short identifier of the source article
(e.g. "montero-2005", "dieguez-aranda-2009").
Character. Full title of the source article.
Character. DOI URL of the source article.
Character. Country where the study was conducted.
Character. Region within the country.
Character. Scientific name of the tree species.
Character. Biomass group ("AGB" or
"BGB").
Character. Sub-group within the biomass group.
Character. Tree component (e.g. "stem",
"bark", "thick branches", "small branches",
"twigs", "leaves", "needles", "roots").
Numeric. Carbon content as a percentage (0-100).
Multiply by the component biomass and divide by 100 to obtain carbon
mass in the same units. NA where not reported in the source.
Numeric. Coefficient of determination of the original model, if reported.
Numeric. Root mean square error of the original model, if reported.
Character. Additional observations from the source article.
Díeguez-Aranda, U., Rojo Alboreca, A., Castedo-Dorado, F., Álvarez González, J.G., Barrio-Anta, M., Crecente-Campo, F., González González, J.M., Pérez-Cruzado, C., Rodríguez Soalleiro, R., López-Sánchez, C.A., Balboa-Murias, M.A., Gorgoso Varela, J.J., Sánchez Rodríguez, F. (2009). Herramientas selvícolas para la gestión forestal sostenible en Galicia. Xunta de Galicia.
Montero, G., Ruiz-Peinado, R., Muñoz, M. (2005). Producción de biomasa y fijación de CO2 por los bosques españoles. Monografías INIA: Serie Forestal n.º 13. Instituto Nacional de Investigación y Tecnología Agraria y Alimentaria, Madrid.
Allometric equations adjusted for Quercus petraea, and Pinus sylvestris in Castille and León (Spain)
eq_biomass_cudjoe_2024(species, component = "AGB", return_rmse = FALSE)eq_biomass_cudjoe_2024(species, component = "AGB", return_rmse = FALSE)
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "stem", "branches"). See Details. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (3):
Pinus sylvestris
Quercus petraea
"mixed" — mixed stand of Pinus sylvestris × Quercus petraea
Available components:
Aboveground group (summed automatically):
"AGB" — total aboveground biomass (sum of all components below)
Individual tree components (species availability varies):
"stem" — stem wood (all species)
"thick branches" — branches > 7 cm (all species)
"medium branches and small branches" — branches < 7 cm (all species)
"leaves" — foliage/needles (Pinus sylvestris only)
Note that no belowground biomass (BGB / roots) or total-tree equations are available in the source paper for this model.
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(),
eq_biomass_menendez_2022()
## Aboveground biomass for a mixed stand eq_biomass_cudjoe_2024("mixed", "AGB")## Aboveground biomass for a mixed stand eq_biomass_cudjoe_2024("mixed", "AGB")
Allometric equations adjusted for Galician (Spain) species
eq_biomass_dieguez_aranda_2009( species, component = "stem", return_r2 = FALSE, return_rmse = FALSE )eq_biomass_dieguez_aranda_2009( species, component = "stem", return_r2 = FALSE, return_rmse = FALSE )
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "tree", "stem", "branches"). See Details. |
return_r2 |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (7):
Betula alba, Eucalyptus globulus, Eucalyptus nitens, Pinus pinaster, Pinus radiata, Pinus sylvestris, Quercus robur
Available components:
Aboveground / belowground groups (summed automatically):
"AGB" — total aboveground biomass
"BGB" — total belowground biomass (roots)
Tree structural groups:
"stem" — stem fraction(s)
"branches" — all branch fractions combined
"roots" — roots (equivalent to BGB)
Individual tree components (species availability varies):
"stem and thick branches" — stem together with thickest branches
"thick branches" — branches > 7 cm
"medium branches" — branches 2–7 cm
"small branches" — branches 0.5–2 cm
"twigs" — branches < 0.5 cm
"dry branches" — dead attached branches
"leaves" — foliage (including needles)
"roots" — coarse roots
Note that total-tree equations ("tree" / "all") are not available for this model.
Also, Eucalyptus globulus, Eucalyptus nitens, and Pinus pinaster lack BGB equations (requesting "BGB" or "roots" will fail).
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(),
eq_biomass_menendez_2022(), eq_biomass_cudjoe_2024()
## Aboveground biomass for Pinus pinaster eq_biomass_dieguez_aranda_2009("Pinus pinaster", "AGB")## Aboveground biomass for Pinus pinaster eq_biomass_dieguez_aranda_2009("Pinus pinaster", "AGB")
Allometric equations adjusted for Quercus petraea and Quercus pyrenaica in Palencia, Spain
eq_biomass_manrique_2017( species, component = "AGB", return_r2 = FALSE, return_rmse = FALSE )eq_biomass_manrique_2017( species, component = "AGB", return_r2 = FALSE, return_rmse = FALSE )
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "stem", "branches"). See Details. |
return_r2 |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (2):
Quercus petraea
Quercus pyrenaica
Available components:
Aboveground group (summed automatically):
"AGB" — total aboveground biomass (sum of all components below)
Individual tree components:
"stem and thick branches" — stem together with branches > 7 cm
"medium branches" — branches 2–7 cm
"small branches" — branches < 2 cm
Note that no belowground biomass (BGB / roots) or total-tree equations are available in the source paper.
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_menendez_2022(),
eq_biomass_cudjoe_2024()
## Aboveground biomass for Quercus petraea eq_biomass_manrique_2017("Quercus petraea", "AGB")## Aboveground biomass for Quercus petraea eq_biomass_manrique_2017("Quercus petraea", "AGB")
Allometric equations for young (<30) plantations of 18 Spanish species including broadleaf and conifer species. Only aboveground biomass.
eq_biomass_menendez_2022(species, return_r2 = FALSE, return_rmse = FALSE)eq_biomass_menendez_2022(species, return_r2 = FALSE, return_rmse = FALSE)
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
return_r2 |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (18):
Betula sp., Fagus sylvatica, Juniperus thurifera, Pinus halepensis, Pinus nigra, Pinus pinaster, Pinus pinea, Pinus radiata, Pinus sylvestris, Quercus faginea, Quercus ilex, Quercus petraea, Quercus pyrenaica, Quercus robur, Quercus suber
Generic equations are also available for functional groups:
"Conifers" — generic equation for conifer species
"Deciduous broadleaves" — generic equation for deciduous broadleaf species
"Evergreen broadleaves" — generic equation for evergreen broadleaf species
Available components:
"AGB" — aboveground biomass (only component available; no component argument needed)
Important — non-standard input variables:
Unlike other biomass models, these equations were fitted on young plantations (< 30 years) and use different predictor variables:
Most species use rcd = root collar diameter (cm), not diameter at breast
height. Pass it via the rcd argument of silv_predict_biomass().
Some species (Pinus halepensis, Pinus nigra, Quercus suber,
Evergreen broadleaves) use bp = biomass packing (m3). Pass it via the
bp argument of silv_predict_biomass().
Betula sp. uses only h (total height).
Note that no belowground biomass (BGB / roots) or total-tree equations are available in the source paper for this model.
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(),
eq_biomass_cudjoe_2024()
## AGB for Fagus sylvatica using root collar diameter eq_biomass_menendez_2022("Fagus sylvatica")## AGB for Fagus sylvatica using root collar diameter eq_biomass_menendez_2022("Fagus sylvatica")
Allometric equations adjusted for Spanish species
eq_biomass_montero_2005(species, component = "stem", return_r2 = FALSE)eq_biomass_montero_2005(species, component = "stem", return_r2 = FALSE)
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "tree", "stem", "branches"). See Details. |
return_r2 |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (35):
Abies alba, Abies pinsapo, Alnus glutinosa, Betula spp., Castanea sativa, Ceratonia siliqua, Erica arborea, Eucalyptus spp., Fagus sylvatica, Fraxinus spp., Ilex canariensis, Juniperus oxycedrus, Juniperus phoenicea, Juniperus thurifera, Laurus azorica, Myrica faya, Olea europaea var. sylvestris, Other broadleaves, Other conifers, Other laurel species, Pinus canariensis, Pinus halepensis, Pinus nigra, Pinus pinaster, Pinus pinea, Pinus radiata, Pinus sylvestris, Pinus uncinata, Populus x euramericana, Quercus canariensis, Quercus faginea, Quercus ilex, Quercus pyrenaica, Quercus robur, Quercus suber
Available components:
Aboveground / belowground groups (summed automatically):
"AGB" — total aboveground biomass
"BGB" — total belowground biomass (roots)
"all" or "tree" — total tree biomass (AGB + BGB)
Tree structural groups:
"stem" — stem fraction(s)
"branches" — all branch fractions combined
"roots" — roots (equivalent to BGB)
Individual tree components (species availability varies):
"stem" — stem wood
"stem and thick branches" — stem together with branches > 7 cm
"thick branches" — branches > 7 cm
"medium branches" — branches 2–7 cm
"small branches" — branches < 2 cm
"leaves" — foliage (including needles)
"roots" — coarse roots
Note that for this model, "tree" (or "all") is an independent regression equation fitted to total-tree data. It was not derived by summing the AGB and BGB equations.
Consequently, there is a numerical discrepancy between the direct "tree" estimation and the sum of separate "AGB" and "BGB" estimations (e.g. for Pinus sylvestris at diameter = 20 cm and height = 10 m, the direct total is 89.1 kg, while AGB + BGB is 115.9 kg, a 24% difference).
Also, the following 6 species have no BGB/roots equations in this model: Abies pinsapo, Erica arborea, Eucalyptus spp., Ilex canariensis, Laurus azorica, Myrica faya (requesting "BGB" or "roots" will fail).
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(),
eq_biomass_menendez_2022(), eq_biomass_cudjoe_2024()
## Aboveground biomass for Pinus pinaster eq_biomass_montero_2005("Pinus pinaster", "AGB")## Aboveground biomass for Pinus pinaster eq_biomass_montero_2005("Pinus pinaster", "AGB")
Allometric equations adjusted for Spanish softwood species
eq_biomass_ruiz_peinado_2011(species, component = "stem", return_rmse = FALSE)eq_biomass_ruiz_peinado_2011(species, component = "stem", return_rmse = FALSE)
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "tree", "stem", "branches"). See Details. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (10):
Abies alba, Abies pinsapo, Juniperus thurifera, Pinus canariensis, Pinus halepensis, Pinus nigra, Pinus pinaster, Pinus pinea, Pinus sylvestris, Pinus uncinata
Available components:
Aboveground / belowground groups (summed automatically):
"AGB" — total aboveground biomass
"BGB" — total belowground biomass (roots)
"tree" — total tree biomass (AGB + BGB)
Tree structural groups:
"stem" — stem wood
"branches" — all branch fractions combined
"roots" — roots (equivalent to BGB)
Individual tree components (species availability varies):
"thick branches" — branches > 7 cm
"thick and medium branches" — branches > 2 cm
"medium branches" — branches 2–7 cm
"small branches and leaves" — branches < 2 cm including leaves/needles
Note that Abies pinsapo does not have a separate BGB equation (requesting "BGB" or "roots" will fail, though "tree" still works via its pre-summed formula).
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(), eq_biomass_menendez_2022(), eq_biomass_cudjoe_2024()
## Aboveground biomass for Pinus pinaster eq_biomass_ruiz_peinado_2011("Pinus pinaster", "AGB")## Aboveground biomass for Pinus pinaster eq_biomass_ruiz_peinado_2011("Pinus pinaster", "AGB")
Allometric equations adjusted for Spanish hardwood species
eq_biomass_ruiz_peinado_2012(species, component = "stem", return_rmse = FALSE)eq_biomass_ruiz_peinado_2012(species, component = "stem", return_rmse = FALSE)
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "tree", "stem", "branches"). See Details. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
Supported species (13):
Alnus glutinosa, Castanea sativa, Ceratonia siliqua, Eucalyptus globulus, Fagus sylvatica, Fraxinus angustifolia, Olea europaea, Populus x euramericana, Quercus canariensis, Quercus faginea, Quercus ilex, Quercus pyrenaica, Quercus suber
Available components:
Aboveground / belowground groups (summed automatically):
"AGB" — total aboveground biomass
"BGB" — total belowground biomass (roots)
"tree" — total tree biomass (AGB + BGB)
Tree structural groups:
"stem" — stem wood
"branches" — all branch fractions combined
"roots" — roots (equivalent to BGB)
Individual tree components (species availability varies):
"stem and thick branches" — stem together with branches > 7 cm
"thick branches" — branches > 7 cm
"thick and medium branches" — branches > 2 cm
"medium branches" — branches 2–7 cm
"small branches" — branches 0.5–2 cm
"small branches and leaves" — branches < 2 cm including leaves
"medium branches, small branches and leaves" — branches < 7 cm including leaves
Note that Eucalyptus globulus does not have a separate BGB equation (requesting "BGB" or "roots" will fail, though "tree" still works via its pre-summed formula).
Users can check all available species and components in the biomass_models dataset provided by the library.
A ModelBiomass object containing the configured model parameters and expressions.
silv_predict_biomass(), biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_manrique_2017(), eq_biomass_menendez_2022(),
eq_biomass_cudjoe_2024()
## Aboveground biomass for Quercus suber eq_biomass_ruiz_peinado_2012("Quercus suber", "AGB")## Aboveground biomass for Quercus suber eq_biomass_ruiz_peinado_2012("Quercus suber", "AGB")
This function is intended to be used in silv_predict_height(). It implements the h-d equations
developed in Vázquez-Veloso et al. (2025). These equations have been developed using the Spanish
National Forest Inventory, and therefore, they should only be applied within Spain. The model includes
parameters for 91 tree species.
eq_hd_vazquez_veloso_2025( species, bioregion = "mediterranean", origin = "natural", mixture = "pure" )eq_hd_vazquez_veloso_2025( species, bioregion = "mediterranean", origin = "natural", mixture = "pure" )
species |
A character string specifying the scientific name of the tree species. It can be a column name if all the species are included in this model. See Details for available species. If not specified, it takes the value "All the species", which corresponds to a generic model applicable to all species. |
bioregion |
The biogeopgrahic region of the species. Available options are:
|
origin |
The origin of the stand. Available options are: |
mixture |
The species available in the stand. Available options are: |
The model adjusts the species-specific coefficients using the selected bioregion, stand origin, and mixture type before returning the model object.
A ModelHD object containing the configured model parameters and metadata.
Vázquez-Veloso, A., Yang, S.-I., Bullock, B.P., Bravo, F., 2025. One model to rule them all: A nationwide height–diameter model for 91 Spanish forest species. Forest Ecology and Management 595, 122981. https://doi.org/10.1016/j.foreco.2025.122981
model <- eq_hd_vazquez_veloso_2025("All the species") silv_predict_height(25, model)model <- eq_hd_vazquez_veloso_2025("All the species") silv_predict_height(25, model)
Inventory data from Spanish National Forest Inventory
inventory_samplesinventory_samples
A tibble
This function calculates the forest fraction cover (Fcov) from LiDAR data. The Fcov in LiDAR is defined as the proportion of first returns above a specified height threshold (default: 5 meters) relative to the total number of first returns.
lid_fcov(z, rn, th = 5)lid_fcov(z, rn, th = 5)
z |
A numeric vector representing the heights of LiDAR returns |
rn |
An integer vector indicating the return number for each LiDAR point.
First returns are identified by a value of |
th |
a numeric vector of length one specifying the height threshold |
A numeric value representing the forest fraction cover, which is the proportion of first returns with heights greater than 5 meters.
# Example data z <- c(2, 6, 10, 4, 15) rn <- c(1, 1, 2, 1, 1) # Calculate forest fraction cover lid_fcov(z, rn)# Example data z <- c(2, 6, 10, 4, 15) rn <- c(1, 1, 2, 1, 1) # Calculate forest fraction cover lid_fcov(z, rn)
LiDAR metric that calculates the LiDAR Height Diversity Index, which
can be used in lidR *_metrics functions
lid_lhdi(z, interval = 0.5)lid_lhdi(z, interval = 0.5)
z |
coordinate Z (height) of the point |
interval |
height of the intervals to calculate the metric |
numeric
Listopad, C. M. C. S., Masters, R. E., Drake, J., Weishampel, J., & Branquinho, C. (2015). Structural diversity indices based on airborne LiDAR as ecological indicators for managing highly dynamic landscapes. Ecological Indicators, 57, 268–279. doi:10.1016/j.ecolind.2015.04.017
z <- c(0.5, 1.2, 1.8, 2.4, 3.1) lid_lhdi(z)z <- c(0.5, 1.2, 1.8, 2.4, 3.1) lid_lhdi(z)
Generic for plotting objects.
plot(x, ..., min_error = 0.01, max_error = 0.5) ## S7 method for class <silviculture::SampleSize> plot(x, ..., min_error = 0.01, max_error = 0.5)plot(x, ..., min_error = 0.01, max_error = 0.5) ## S7 method for class <silviculture::SampleSize> plot(x, ..., min_error = 0.01, max_error = 0.5)
x |
Object to plot. |
... |
Other arguments passed to methods. |
min_error |
A numeric value specifying the minimum relative error to consider (default is 0.01). |
max_error |
A numeric value specifying the maximum relative error to consider (default is 0.5). |
Usually called for side-effects (producing a plot).
silv_predict_carbon() calculates the carbon content of a tree component based on its
predicted biomass. It uses species- and component-specific carbon percentages
from the package's internal carbon_models database.
silv_predict_carbon_auto() is a vectorized function that automatically selects
the best available carbon model for each row based on a provided priority list.
If the exact species is not found, it attempts a genus-level fallback (e.g., "Pinus spp.").
silv_predict_carbon( biomass, species, component, model = "montero-2005", quiet = FALSE ) silv_predict_carbon_auto( biomass, species, component, priority = c("montero-2005", "dieguez-aranda-2009"), quiet = FALSE )silv_predict_carbon( biomass, species, component, model = "montero-2005", quiet = FALSE ) silv_predict_carbon_auto( biomass, species, component, priority = c("montero-2005", "dieguez-aranda-2009"), quiet = FALSE )
biomass |
A numeric vector of predicted biomass (in kg). |
species |
A character vector of tree species (e.g., |
component |
A character string or vector specifying the tree component
(e.g., |
model |
A character string specifying the carbon model to use (e.g., |
quiet |
Logical. If |
priority |
A character vector specifying the order of preference for carbon models.
Default is |
For silv_predict_carbon(): A numeric vector of predicted carbon (in kg).
Returns NA if the species/component combination is not supported by the model.
For silv_predict_carbon_auto(): A data.frame with two columns:
carbon: The predicted carbon (in kg).
carbon_model: The model and species level used (e.g., "montero-2005" or "montero-2005 (genus fallback)").
# 1. Vector-based calculation: calculate stem carbon for Pinus pinaster biomass_vector <- c(120.5, 230.1, 85.4) species_vector <- c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster") carbon_vector <- silv_predict_carbon( biomass = biomass_vector, species = species_vector, component = "stem", model = "montero-2005" ) print(carbon_vector) # 2. Vector-based calculation with row-wise auto-selection & genus fallback carbon_df <- silv_predict_carbon_auto( biomass = c(120.5, 95.0), species = c("Pinus pinaster", "Pinus radiata"), # Pinus radiata triggers genus fallback component = c("stem", "roots") ) print(carbon_df) # 3. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus sylvestris", "Quercus robur"), biomass_kg = c(150.0, 180.5, 220.0), component = c("stem", "roots", "stem") ) # Apply row-wise auto-selection to the entire dataset carbon_results <- silv_predict_carbon_auto( biomass = inventory$biomass_kg, species = inventory$species, component = inventory$component ) # Combine and display results inventory_with_carbon <- cbind(inventory, carbon_results) print(inventory_with_carbon)# 1. Vector-based calculation: calculate stem carbon for Pinus pinaster biomass_vector <- c(120.5, 230.1, 85.4) species_vector <- c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster") carbon_vector <- silv_predict_carbon( biomass = biomass_vector, species = species_vector, component = "stem", model = "montero-2005" ) print(carbon_vector) # 2. Vector-based calculation with row-wise auto-selection & genus fallback carbon_df <- silv_predict_carbon_auto( biomass = c(120.5, 95.0), species = c("Pinus pinaster", "Pinus radiata"), # Pinus radiata triggers genus fallback component = c("stem", "roots") ) print(carbon_df) # 3. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus sylvestris", "Quercus robur"), biomass_kg = c(150.0, 180.5, 220.0), component = c("stem", "roots", "stem") ) # Apply row-wise auto-selection to the entire dataset carbon_results <- silv_predict_carbon_auto( biomass = inventory$biomass_kg, species = inventory$species, component = inventory$component ) # Combine and display results inventory_with_carbon <- cbind(inventory, carbon_results) print(inventory_with_carbon)
Calculates Basal Area in square meters.
silv_basal_area(diameter, ntrees = NULL, units = "cm")silv_basal_area(diameter, ntrees = NULL, units = "cm")
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
units |
The units of the diameter (one of |
The function uses the next formula:
where G is the basal area in , and D is the diameter in the units
specified in the function. It is recommended to use the squared mean diameter
calculated with silv_sqrmean_diameter
A numeric vector
## calculate G for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), dg = silv_sqrmean_diameter(dclass, ntrees_ha), g = silv_basal_area(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate individual basal area silv_basal_area(c(23, 11, 43.5, 94))## calculate G for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), dg = silv_sqrmean_diameter(dclass, ntrees_ha), g = silv_basal_area(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate individual basal area silv_basal_area(c(23, 11, 43.5, 94))
Computes the biomass of a tree species using species-specific allometric equations (in kg).
silv_biomass( diameter = NULL, height = NULL, ntrees = NULL, species = NULL, component = "stem", model = "ruiz-peinado-2012", return_rmse = FALSE, quiet = FALSE )silv_biomass( diameter = NULL, height = NULL, ntrees = NULL, species = NULL, component = "stem", model = "ruiz-peinado-2012", return_rmse = FALSE, quiet = FALSE )
diameter |
A numeric vector of tree diameters (in cm). |
height |
A numeric vector of tree heights (in m). |
ntrees |
An optional numeric value indicating the number of trees in this diameter-height class. Defaults to 1 if NULL. |
species |
A character string specifying the scientific name of the tree species. See Details for available species. |
component |
A character string specifying the tree component for biomass calculation (e.g., "tree", "stem", "branches"). See Details. |
model |
A character string indicating the ID of the publication in which the model was developed. Currently supported models: "ruiz-peinado-2012" (hardwood species in Spain) and "ruiz-peinado-2011" (softwood species in Spain). See Details. |
return_rmse |
A logical value. If TRUE, the function returns the root mean squared error (RMSE) of the selected model instead of the biomass value. |
quiet |
A logical value. If TRUE, suppresses any informational messages. |
The function estimates biomass using validated allometric models available in the dataset biomass_models. The available models include:
ruiz-peinado-2011: Developed for softwood species in Spain.
ruiz-peinado-2012: Developed for hardwood species in Spain.
Users can check the list of supported species and their corresponding components in biomass_models.
If you would like to suggest additional models, please open a new issue on GitHub.
A numeric vector of biomass values (in kg). If return_rmse = TRUE, returns the RMSE instead.
# Calculate biomass for a single tree silv_biomass( diameter = 45, height = 22, species = "Pinus pinaster", model = "ruiz-peinado-2011" )# Calculate biomass for a single tree silv_biomass( diameter = 45, height = 22, species = "Pinus pinaster", model = "ruiz-peinado-2011" )
Calculates the Hart Index or the Hart-Becking Index for even-aged stands
silv_density_hart(h0, ntrees, which = c("hart", "hart-becking"))silv_density_hart(h0, ntrees, which = c("hart", "hart-becking"))
h0 |
Numeric vector with dominant height |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
which |
A character with the name of the index (either |
The spacing index can be used to determine whether a thinning is needed or not, and also to determine how intense it should be.
Hart Index: it assumes even-aged stands with square planting pattern.
Hart-Brecking Index: it assumes triangular planting pattern.
A numeric vector
Assmann, E. (1970) The principles of forest yield study: Studies in the organic production, structure, increment, and yield of forest stands. Pergamon Press, Oxford.
library(dplyr) ## Calculate spacing index for each plot inventory_samples |> summarise( h0 = silv_stand_dominant_height(diameter, height), ntrees = n(), .by = plot_id ) |> ## calculate number of trees per hectare mutate(ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 14.1)) |> mutate(spacing = silv_density_hart(h0, ntrees_ha))library(dplyr) ## Calculate spacing index for each plot inventory_samples |> summarise( h0 = silv_stand_dominant_height(diameter, height), ntrees = n(), .by = plot_id ) |> ## calculate number of trees per hectare mutate(ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 14.1)) |> mutate(spacing = silv_density_hart(h0, ntrees_ha))
Calculates number of trees per hectare for a given plot size and shape
silv_density_ntrees_ha(ntrees, plot_size, plot_shape = "circular")silv_density_ntrees_ha(ntrees, plot_size, plot_shape = "circular")
ntrees |
A numeric vector representing the number of trees in a sampling plot |
plot_size |
A numeric vector of length one for circular radius in meters; or a numeric vector of length two for each side of a rectangular plot shape |
plot_shape |
The shape of the sampling plot. Either |
A numeric vector
library(dplyr) ## Circular plot of 10 meters radius inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_density_ntrees_ha(n, plot_size = 10) ) ## Rectangular plot of 10x15 meters inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_density_ntrees_ha( n, plot_size = c(10, 15), plot_shape = "rectangular" ) )library(dplyr) ## Circular plot of 10 meters radius inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_density_ntrees_ha(n, plot_size = 10) ) ## Rectangular plot of 10x15 meters inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_density_ntrees_ha( n, plot_size = c(10, 15), plot_shape = "rectangular" ) )
The Stand Density Index (SDI) is relationship between the average tree size and density of trees per hectare.
silv_density_sdi(ntrees, dg, classify = FALSE, max_sdi = NULL)silv_density_sdi(ntrees, dg, classify = FALSE, max_sdi = NULL)
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
dg |
Numeric vector of quadratic mean diameters |
classify |
whether to classify the values using USDA thresholds |
max_sdi |
used when |
The SDI has different interpretation depending on the species, location, and also
the management type (even-aged, uneven-aged...). The value of maximum SDI must
be determined from the literature and used carefully. The option classify = TRUE
will use this value to classify the SDI in low density (<24%), moderate density (24-35%),
high density (34-55%), and extremely high density (>55%).
A numeric vector
## calculate SDI for a Pinus sulvestris stand (max 990) silv_density_sdi(ntrees = 800, dg = 23.4, max_sdi = 990) ## check base classification (other can be used) silv_density_sdi(ntrees = 800, dg = 23.4, classify = TRUE, max_sdi = 990)## calculate SDI for a Pinus sulvestris stand (max 990) silv_density_sdi(ntrees = 800, dg = 23.4, max_sdi = 990) ## check base classification (other can be used) silv_density_sdi(ntrees = 800, dg = 23.4, classify = TRUE, max_sdi = 990)
Classifies the measured diameters into classes of a specified length
silv_diametric_class( diameter, dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, return_intervals = FALSE )silv_diametric_class( diameter, dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, return_intervals = FALSE )
diameter |
A numeric vector of diameters |
dmin |
The minimum inventory diameter in centimeters |
dmax |
The maximum inventory diameter in centimeters. Values that
are greater than |
class_length |
The length of the class in centimeters |
include_lowest |
Logical. If TRUE (the default), the intervals are
[dim1, dim2) |
return_intervals |
If FALSE, it returns the intervals. Otherwise (the default), it returns the class center |
A numeric vector
library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter))library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter))
Calculates the dominant height using the Assman equation or the Hart equation
silv_dominant_height(diameter, height, ntrees = NULL, which = "assman")silv_dominant_height(diameter, height, ntrees = NULL, which = "assman")
diameter |
Numeric vector with diameter classes |
height |
Numeric vector with averaged heights by diameter class |
ntrees |
Optional. Numeric vector with number of trees per hectare. Use this argument when you have aggregated data by diametric classes (see details). |
which |
The method to calculate the dominant height (see details) |
The dominant height is the mean height of dominant trees, which is
less affected than overall mean height by thinning or other treatments.
Assman: calculates the as the mean height of the 100 thickest
trees per hectare
Hart: calculates the as the mean height of the 100 tallest
trees per hectare
When ntrees = NULL, the function will assume that each diameter and height
belongs to only one tree. If you have data aggregated by hectare, you'll use the
number of trees per hectare in this argument.
A numeric vector
Assmann, E. (1970) The principles of forest yield study: Studies in the organic production, structure, increment, and yield of forest stands. Pergamon Press, Oxford.
## calculate h0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), h0 = silv_dominant_height(dclass, height, ntrees_ha), .by = c(plot_id, species) )## calculate h0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), h0 = silv_dominant_height(dclass, height, ntrees_ha), .by = c(plot_id, species) )
silv_lorey_height(height, g, ntrees = NULL)silv_lorey_height(height, g, ntrees = NULL)
height |
Numeric vector of heights |
g |
Numeric vector of basal areas |
ntrees |
Optional. Numeric vector of number of trees per hectare. Use this argument when you have aggregated data by diametric classes (see details). |
Tree's mean height weighted by basal area
The function calculates Lorey's mean height according to:
When ntrees is not provided (i.e. ntrees = NULL) the formula is simply
the weighted mean of the provided heights and basal areas:
A numeric vector
## Calculate Lorey's Height by plot and species library(dplyr) inventory_samples |> mutate(g = silv_basal_area(diameter)) |> summarise( lh = silv_lorey_height(height, g), .by = c(plot_id, species) )## Calculate Lorey's Height by plot and species library(dplyr) inventory_samples |> mutate(g = silv_basal_area(diameter)) |> summarise( lh = silv_lorey_height(height, g), .by = c(plot_id, species) )
Calculates number of trees per hectare for a given plot size and shape
silv_ntrees_ha(ntrees, plot_size, plot_shape = "circular")silv_ntrees_ha(ntrees, plot_size, plot_shape = "circular")
ntrees |
A numeric vector representing the number of trees in a sampling plot |
plot_size |
A numeric vector of length one for circular radius in meters; or a numeric vector of length two for each side of a rectangular plot shape |
plot_shape |
The shape of the sampling plot. Either |
A numeric vector
library(dplyr) ## Circular plot of 10 meters radius inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_ntrees_ha(n, plot_size = 10) ) ## Rectangular plot of 10x15 meters inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_ntrees_ha( n, plot_size = c(10, 15), plot_shape = "rectangular" ) )library(dplyr) ## Circular plot of 10 meters radius inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_ntrees_ha(n, plot_size = 10) ) ## Rectangular plot of 10x15 meters inventory_samples |> count(plot_id, species) |> mutate( ntrees_ha = silv_ntrees_ha( n, plot_size = c(10, 15), plot_shape = "rectangular" ) )
Computes the biomass of a tree species using species-specific allometric equations (in kg). Currently, only equations for Spain are available.
silv_predict_biomass( diameter = NULL, height = NULL, model, ntrees = NULL, rcd = NULL, bp = NULL, quiet = FALSE )silv_predict_biomass( diameter = NULL, height = NULL, model, ntrees = NULL, rcd = NULL, bp = NULL, quiet = FALSE )
diameter |
A numeric vector of tree diameters at breast height (in cm). |
height |
A numeric vector of tree heights (in m). |
model |
A function. A function with the structure |
ntrees |
An optional numeric value indicating the number of trees in
this diameter-height class. Defaults to 1 if |
rcd |
An optional numeric vector of root collar diameters (in cm). Required
for |
bp |
An optional numeric vector of biomass packing values (in m3). Required
for a subset of species in |
quiet |
A logical value. If |
The function estimates biomass using validated allometric models available in the dataset biomass_models. The available models include:
eq_biomass_ruiz_peinado_2011(): Developed for softwood species in Spain.
eq_biomass_ruiz_peinado_2012(): Developed for hardwood species in Spain.
eq_biomass_montero_2005(): Developed for 35 Spanish species.
eq_biomass_dieguez_aranda_2009(): Developed for 7 Galician species.
eq_biomass_manrique_2017(): Developed for Quercus petraea and Quercus pyrenaica.
eq_biomass_menendez_2022(): Developed for young plantations (< 30 years) of 18
Spanish species. Uses rcd (root collar diameter) instead of diameter; some species
require bp (biomass packing) instead of rcd.
eq_biomass_cudjoe_2024(): Developed for Pinus sylvestris and Quercus petraea
in Castille and León, Spain.
Users can check the list of supported species and their corresponding components in biomass_models.
If you would like to suggest additional models, please open a new issue on GitHub.
A numeric vector with predicted tree biomass (kg).
biomass_models, eq_biomass_montero_2005(), eq_biomass_dieguez_aranda_2009(),
eq_biomass_ruiz_peinado_2011(), eq_biomass_ruiz_peinado_2012(), eq_biomass_manrique_2017(),
eq_biomass_menendez_2022(), eq_biomass_cudjoe_2024()
# 1. Vector-based calculation: predict stem/tree biomass for Pinus pinaster model <- eq_biomass_ruiz_peinado_2011("Pinus pinaster") predicted_biomass <- silv_predict_biomass( diameter = c(20, 25, 30), height = c(15, 17, 18), model = model ) print(predicted_biomass) # 2. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4), height_m = c(14.0, 16.5, 19.0) ) # Apply prediction and append a new column to the dataset inventory$biomass_kg <- silv_predict_biomass( diameter = inventory$dbh_cm, height = inventory$height_m, model = model ) print(inventory) # 3. Young plantation example (Menendez 2022 model) using rcd and bp # Menendez 2022 equations use root collar diameter (rcd) and/or biomass packing (bp) model_menendez <- eq_biomass_menendez_2022("Pinus pinaster") predicted_young_pinaster <- silv_predict_biomass( rcd = c(5.2, 7.1, 9.4), # Root collar diameter in cm height = c(2.1, 3.2, 4.5), # Height in m model = model_menendez ) print(predicted_young_pinaster) # For Pinus halepensis, Menendez 2022 requires biomass packing (bp) model_halepensis <- eq_biomass_menendez_2022("Pinus halepensis") predicted_young_halepensis <- silv_predict_biomass( bp = c(0.005, 0.012), # Biomass packing in m3 model = model_halepensis ) print(predicted_young_halepensis)# 1. Vector-based calculation: predict stem/tree biomass for Pinus pinaster model <- eq_biomass_ruiz_peinado_2011("Pinus pinaster") predicted_biomass <- silv_predict_biomass( diameter = c(20, 25, 30), height = c(15, 17, 18), model = model ) print(predicted_biomass) # 2. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4), height_m = c(14.0, 16.5, 19.0) ) # Apply prediction and append a new column to the dataset inventory$biomass_kg <- silv_predict_biomass( diameter = inventory$dbh_cm, height = inventory$height_m, model = model ) print(inventory) # 3. Young plantation example (Menendez 2022 model) using rcd and bp # Menendez 2022 equations use root collar diameter (rcd) and/or biomass packing (bp) model_menendez <- eq_biomass_menendez_2022("Pinus pinaster") predicted_young_pinaster <- silv_predict_biomass( rcd = c(5.2, 7.1, 9.4), # Root collar diameter in cm height = c(2.1, 3.2, 4.5), # Height in m model = model_menendez ) print(predicted_young_pinaster) # For Pinus halepensis, Menendez 2022 requires biomass packing (bp) model_halepensis <- eq_biomass_menendez_2022("Pinus halepensis") predicted_young_halepensis <- silv_predict_biomass( bp = c(0.005, 0.012), # Biomass packing in m3 model = model_halepensis ) print(predicted_young_halepensis)
Evaluates vectors of tree species, diameters, and heights, and automatically
selects the best available allometric model based on a specified priority.
If tree height is not provided, is NA, or is 0, the function automatically
falls back to the eq_biomass_montero_2005 model.
silv_predict_biomass_auto( species, diameter, height = NULL, component = "tree", ntrees = NULL, rcd = NULL, bp = NULL, priority = c("ruiz-peinado-2011", "ruiz-peinado-2012", "montero-2005", "dieguez-aranda-2009", "manrique-2017", "menendez-2022", "cudjoe-2024"), quiet = FALSE )silv_predict_biomass_auto( species, diameter, height = NULL, component = "tree", ntrees = NULL, rcd = NULL, bp = NULL, priority = c("ruiz-peinado-2011", "ruiz-peinado-2012", "montero-2005", "dieguez-aranda-2009", "manrique-2017", "menendez-2022", "cudjoe-2024"), quiet = FALSE )
species |
A character vector specifying the scientific names of the tree species. |
diameter |
A numeric vector of tree diameters at breast height (in cm). |
height |
An optional numeric vector of tree heights (in m). Defaults to |
component |
A character string specifying the tree component for biomass
calculation (e.g., "tree", "stem", "branches"). Defaults to |
ntrees |
An optional numeric vector indicating the number of trees in
each class. Defaults to |
rcd |
An optional numeric vector of root collar diameters (in cm). Required
for young plantation equations ( |
bp |
An optional numeric vector of biomass packing values (in m3). Required for some species in young plantation equations. |
priority |
A character vector specifying the priority order for model selection.
Defaults to |
quiet |
A logical value. If |
A data.frame containing two columns:
biomass: Numeric vector of predicted biomass values (in kg).
biomass_model: Character vector specifying the model ID used.
# 1. Vector-based calculation: automatic model selection for mixed species species_vec <- c("Pinus pinaster", "Quercus petraea") d_vec <- c(20, 25) h_vec <- c(12, 14) auto_results <- silv_predict_biomass_auto(species_vec, d_vec, h_vec) print(auto_results) # 2. Vector-based calculation: fallback to Montero 2005 when height is missing fallback_results <- silv_predict_biomass_auto(species_vec, d_vec, height = NULL) print(fallback_results) # 3. Dataset-based tutorial: apply to a mixed-species forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Quercus petraea", "Pinus sylvestris"), dbh_cm = c(22.5, 18.0, 31.2), height_m = c(15.0, 11.5, 18.0) ) # Run auto-selection and bind the results directly biomass_data <- silv_predict_biomass_auto( species = inventory$species, diameter = inventory$dbh_cm, height = inventory$height_m ) inventory_with_biomass <- cbind(inventory, biomass_data) print(inventory_with_biomass)# 1. Vector-based calculation: automatic model selection for mixed species species_vec <- c("Pinus pinaster", "Quercus petraea") d_vec <- c(20, 25) h_vec <- c(12, 14) auto_results <- silv_predict_biomass_auto(species_vec, d_vec, h_vec) print(auto_results) # 2. Vector-based calculation: fallback to Montero 2005 when height is missing fallback_results <- silv_predict_biomass_auto(species_vec, d_vec, height = NULL) print(fallback_results) # 3. Dataset-based tutorial: apply to a mixed-species forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Quercus petraea", "Pinus sylvestris"), dbh_cm = c(22.5, 18.0, 31.2), height_m = c(15.0, 11.5, 18.0) ) # Run auto-selection and bind the results directly biomass_data <- silv_predict_biomass_auto( species = inventory$species, diameter = inventory$dbh_cm, height = inventory$height_m ) inventory_with_biomass <- cbind(inventory, biomass_data) print(inventory_with_biomass)
Predicts all available individual biomass components (e.g., stem, bark, branches, roots) for the given trees in a single call, returning a wide data frame.
silv_predict_biomass_components( species, diameter, height = NULL, model_fn, ntrees = NULL, rcd = NULL, bp = NULL, quiet = TRUE )silv_predict_biomass_components( species, diameter, height = NULL, model_fn, ntrees = NULL, rcd = NULL, bp = NULL, quiet = TRUE )
species |
A character vector specifying the scientific names of the tree species. |
diameter |
A numeric vector of tree diameters at breast height (in cm). |
height |
An optional numeric vector of tree heights (in m). Defaults to |
model_fn |
A function or character string. The constructer function of the model
(e.g., |
ntrees |
An optional numeric vector indicating the number of trees in
each class. Defaults to |
rcd |
An optional numeric vector of root collar diameters (in cm). |
bp |
An optional numeric vector of biomass packing values (in m3). |
quiet |
A logical value. If |
A data.frame with the columns species, diameter (cm),
height (m, if provided), and one additional numeric column (in kg) for each
individual biomass component available for the selected species and model.
# 1. Vector-based calculation: predict all components for Pinus pinaster comp_results <- silv_predict_biomass_components( species = c("Pinus pinaster", "Pinus pinaster"), diameter = c(20, 25), height = c(12, 15), model_fn = eq_biomass_ruiz_peinado_2011 ) print(comp_results) # 2. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4), height_m = c(14.0, 16.5, 19.0) ) # Predict components for the entire dataset comp_df <- silv_predict_biomass_components( species = inventory$species, diameter = inventory$dbh_cm, height = inventory$height_m, model_fn = "ruiz-peinado-2011" ) # Combine and display results (excluding repeated identifier columns) inventory_with_components <- cbind( inventory, comp_df[, -(1:3)] ) print(inventory_with_components)# 1. Vector-based calculation: predict all components for Pinus pinaster comp_results <- silv_predict_biomass_components( species = c("Pinus pinaster", "Pinus pinaster"), diameter = c(20, 25), height = c(12, 15), model_fn = eq_biomass_ruiz_peinado_2011 ) print(comp_results) # 2. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4), height_m = c(14.0, 16.5, 19.0) ) # Predict components for the entire dataset comp_df <- silv_predict_biomass_components( species = inventory$species, diameter = inventory$dbh_cm, height = inventory$height_m, model_fn = "ruiz-peinado-2011" ) # Combine and display results (excluding repeated identifier columns) inventory_with_components <- cbind( inventory, comp_df[, -(1:3)] ) print(inventory_with_components)
Estimates total tree height (m) using height-diameter (h-d) equations. Currently, only models developed for Spain are available.
silv_predict_height( diameter, model = eq_hd_vazquez_veloso_2025("All the species"), quiet = FALSE )silv_predict_height( diameter, model = eq_hd_vazquez_veloso_2025("All the species"), quiet = FALSE )
diameter |
Numeric vector with diameters in cm (DBH). |
model |
A ModelHD object. An object configured via the |
quiet |
A logical value. If TRUE, suppresses any informational messages. |
The function estimates total tree height (in meters) using diameter at breast height (in centimeters), and may require additional information depending on the specific model. See each model’s documentation for details.
A numeric vector with predicted heights (m).
References for the models available:
eq_hd_vazquez_veloso_2025(): Vázquez-Veloso, A., Yang, S.-I., Bullock, B.P., Bravo, F., 2025. One model to rule them all:
A nationwide height–diameter model for 91 Spanish forest species. Forest Ecology and Management 595, 122981.
https://doi.org/10.1016/j.foreco.2025.122981
# 1. Predict height using the default model (Vázquez-Veloso 2025 generic model) predicted_heights_default <- silv_predict_height(diameter = c(20, 25, 30)) print(predicted_heights_default) # 2. Load the S7 ModelHD object for Pinus pinaster model <- eq_hd_vazquez_veloso_2025("Pinus pinaster") # 3. Vector-based calculation: predict tree heights from diameters diameters <- c(20, 25, 30) predicted_heights <- silv_predict_height(diameter = diameters, model = model) print(predicted_heights) # 4. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4) ) # Apply prediction and append a new column to the dataset inventory$height_m <- silv_predict_height( diameter = inventory$dbh_cm, model = model ) print(inventory)# 1. Predict height using the default model (Vázquez-Veloso 2025 generic model) predicted_heights_default <- silv_predict_height(diameter = c(20, 25, 30)) print(predicted_heights_default) # 2. Load the S7 ModelHD object for Pinus pinaster model <- eq_hd_vazquez_veloso_2025("Pinus pinaster") # 3. Vector-based calculation: predict tree heights from diameters diameters <- c(20, 25, 30) predicted_heights <- silv_predict_height(diameter = diameters, model = model) print(predicted_heights) # 4. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, species = c("Pinus pinaster", "Pinus pinaster", "Pinus pinaster"), dbh_cm = c(18.5, 22.1, 29.4) ) # Apply prediction and append a new column to the dataset inventory$height_m <- silv_predict_height( diameter = inventory$dbh_cm, model = model ) print(inventory)
Computes four volume metrics (in dm^3) for one or more trees using the allometric equations from the 3rd and 4th Spanish National Forest Inventory (SNFI3/SNFI4), as documented by MITECO (Anexo 19).
silv_predict_snfi_volume( province, species, dbh = NULL, h = NULL, dnm = NULL, quality = "default", quiet = FALSE )silv_predict_snfi_volume( province, species, dbh = NULL, h = NULL, dnm = NULL, quality = "default", quiet = FALSE )
province |
A character or numeric vector. Province name (e.g.
|
species |
A character or numeric vector. Species scientific name (e.g.
|
dbh |
A numeric vector of diameter at breast height in cm. |
h |
A numeric vector of tree heights in m. Optional for some models (e.g. SNFI3 model 14), but required by most VCC equations. |
dnm |
A numeric vector of mean plot diameter in cm. Required only when the IAVC equation uses model 13. |
quality |
A character or numeric vector. Quality/shape class ( |
quiet |
A logical value. If |
For each province, SNFI4 data are preferred. When a province is not covered by SNFI4 (11 provinces), the function falls back to SNFI3 automatically. SNFI3 also provides a supplementary file for species not present in the standard provincial tables.
| Component | Models used |
| VCC | 1, 11 |
| VSC | 7 |
| IAVC | 8, 13, 14, 16, 17, 18, 19, 20, 21, 25 |
| VLE | 10, 12 |
Full model equations are available in Anexo 19 of the MITECO SIG documentation (see References).
Inputs: dbh and dnm in cm (converted to mm internally),
h in m. All outputs in dm^3.
A data.frame with one row per input tree and five columns:
vccMerchantable volume with bark (dm^3).
vscMerchantable volume without bark (dm^3).
iavcAnnual volume increment with bark (dm^3).
vleCoarse firewood volume (dm^3).
snfi_versionDataset used: "SNFI4" or "SNFI3".
Any component for which parameters are missing or a required input is
NA returns NA for that column, without stopping execution.
MITECO. 4th Spanish National Forest Inventory - SIG database codes. https://www.miteco.gob.es/content/dam/miteco/es/biodiversidad/temas/inventarios-nacionales/documentador_sig_tcm30-536622.pdf
MITECO. 3rd Spanish National Forest Inventory - SIG database codes. https://www.miteco.gob.es/content/dam/miteco/es/biodiversidad/servicios/banco-datos-naturaleza/documentador_bdcampo_ifn3_tcm30-282240.pdf
silv_snfi_provinces(), silv_snfi_species(), silv_tree_volume()
# 1. Vector-based calculation: single tree (Pinus radiata in Alava, province 1, code 28) single_tree <- silv_predict_snfi_volume( province = 1, species = 28, dbh = 20, h = 15, dnm = 23 ) print(single_tree) # 2. Vector-based calculation: multiple trees with province and species by name multi_trees <- silv_predict_snfi_volume( province = c("Araba/Álava", "Cantabria"), species = c("Pinus radiata", "Pinus radiata"), dbh = c(20, 25), h = c(15, 18), dnm = c(23, 26) ) print(multi_trees) # 3. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, province = c("Cantabria", "Cantabria", "Araba/Álava"), species = c("Pinus radiata", "Pinus radiata", "Pinus sylvestris"), dbh_cm = c(20.5, 28.0, 18.2), height_m = c(15.2, 18.5, 12.0) ) # Apply the SNFI volume estimation functions row-wise across the dataset volume_results <- silv_predict_snfi_volume( province = inventory$province, species = inventory$species, dbh = inventory$dbh_cm, h = inventory$height_m ) # Combine and display results inventory_with_volume <- cbind(inventory, volume_results) print(inventory_with_volume)# 1. Vector-based calculation: single tree (Pinus radiata in Alava, province 1, code 28) single_tree <- silv_predict_snfi_volume( province = 1, species = 28, dbh = 20, h = 15, dnm = 23 ) print(single_tree) # 2. Vector-based calculation: multiple trees with province and species by name multi_trees <- silv_predict_snfi_volume( province = c("Araba/Álava", "Cantabria"), species = c("Pinus radiata", "Pinus radiata"), dbh = c(20, 25), h = c(15, 18), dnm = c(23, 26) ) print(multi_trees) # 3. Dataset-based tutorial: apply to a forest inventory data frame inventory <- data.frame( tree_id = 1:3, province = c("Cantabria", "Cantabria", "Araba/Álava"), species = c("Pinus radiata", "Pinus radiata", "Pinus sylvestris"), dbh_cm = c(20.5, 28.0, 18.2), height_m = c(15.2, 18.5, 12.0) ) # Apply the SNFI volume estimation functions row-wise across the dataset volume_results <- silv_predict_snfi_volume( province = inventory$province, species = inventory$species, dbh = inventory$dbh_cm, h = inventory$height_m ) # Combine and display results inventory_with_volume <- cbind(inventory, volume_results) print(inventory_with_volume)
silv_sample_size( x, plot_size, total_area, method = "random", max_error = 0.05, conf_level = 0.95, max_iter = 1000, quiet = FALSE )silv_sample_size( x, plot_size, total_area, method = "random", max_error = 0.05, conf_level = 0.95, max_iter = 1000, quiet = FALSE )
x |
vector of field survey |
plot_size |
a numeric vector of length one with plot size in squared meters |
total_area |
total area of the study area in squared meters |
method |
sampling method. Available options are |
max_error |
maximum allowed error |
conf_level |
confidence level |
max_iter |
maximum number of iteration to find the plot size |
quiet |
if |
SampleSize object
## pilot inventory measuring 4 plots of 25x25 meters ## total forest area 15 ha ## measured variable (x): basal area per hectare silv_sample_size( x = c(33, 37.5, 42, 35.2), plot_size = 25 * 25, # squared plot of 25x25 total_area = 15 * 1e4, # 15 ha max_error = 0.05, conf_level = 0.95, max_iter = 100 )## pilot inventory measuring 4 plots of 25x25 meters ## total forest area 15 ha ## measured variable (x): basal area per hectare silv_sample_size( x = c(33, 37.5, 42, 35.2), plot_size = 25 * 25, # squared plot of 25x25 total_area = 15 * 1e4, # 15 ha max_error = 0.05, conf_level = 0.95, max_iter = 100 )
Calculates the sample size needed for a SRS inventory, estimated from pilot inventory data.
silv_sample_size_simple( x, plot_size, total_area, max_error = 0.05, conf_level = 0.95, max_iter = 1000, quiet = FALSE )silv_sample_size_simple( x, plot_size, total_area, max_error = 0.05, conf_level = 0.95, max_iter = 1000, quiet = FALSE )
x |
vector of the variable measured in the pilot inventory (e.g. basal area, volume) |
plot_size |
a numeric vector of length one with plot size in squared meters |
total_area |
total area of the study area in squared meters |
max_error |
maximum allowed relative error |
conf_level |
confidence level |
max_iter |
maximum number of iteration to find the plot size |
quiet |
if |
Sample size is very important to be optimized, since a small sample size will entail a higher error, while a huge sample size will entail higher costs. The SRS is typically used for random sampling, although it might be used also for regular sampling. The number of samples is calculated using the expression:
Where:
t: the value of student's t for given sample size of the pilot inventory
CV: the coefficient of variation of x
: the relative error (max_error)
N: the size of the pilot inventory
x is a variable measured in a pilot inventory. Let's say we measure forest
variables in 10 pilot plots, aiming at basal area measurement so we have to
measure only the DBH. After some calculations, we will have the basal area
per hectare in each of the 10 plots. The sample size is then calculated from
the variation of these values and the error that we will allow.
SimpleSampleSize object
## pilot inventory measuring 4 plots of 25x25 meters ## total forest area 15 ha ## measured variable (x): basal area per hectare silv_sample_size_simple( x = c(33, 37.5, 42, 35.2), plot_size = 25 * 25, # squared plot of 25x25 total_area = 15 * 1e4, # 15 ha max_error = 0.05, conf_level = 0.95, max_iter = 100 )## pilot inventory measuring 4 plots of 25x25 meters ## total forest area 15 ha ## measured variable (x): basal area per hectare silv_sample_size_simple( x = c(33, 37.5, 42, 35.2), plot_size = 25 * 25, # squared plot of 25x25 total_area = 15 * 1e4, # 15 ha max_error = 0.05, conf_level = 0.95, max_iter = 100 )
Calculates the sample size needed for a stratified inventory, estimated from pilot inventory data.
silv_sample_size_stratified( data, x, strata, total_area, plot_size, method = "optimal", cost = NA, max_error = 0.05, conf_level = 0.95, max_iter = 1000, currency = "EUR", quiet = FALSE )silv_sample_size_stratified( data, x, strata, total_area, plot_size, method = "optimal", cost = NA, max_error = 0.05, conf_level = 0.95, max_iter = 1000, currency = "EUR", quiet = FALSE )
data |
a |
x |
name of the variable in |
strata |
name of the variable in |
total_area |
name of the variable in |
plot_size |
a numeric vector of length one with plot size in squared meters |
method |
a charater vector of length one with the id of the method. Available
options are |
cost |
name of the variable in |
max_error |
maximum allowed relative error |
conf_level |
confidence level |
max_iter |
maximum number of iteration to find the plot size |
currency |
currency to be shown in console output when using |
quiet |
if |
Stratified Sampling calculates the number of plots to be inventored in different strata. For instance, you might have Pinus sylvestris and Pinus pinaster plots in the same forest, and you might want to get the optimal number of plots for field inventory of each stratum, for a given maximum relative error (e.g. 5%), and with a certain level of confidence (e.g 95%). Of course, the area of P. sylvestris will be different than the area occupied by P. pinaster. For instance, the total area of P. sylvestris could be 100 ha, while the area of P. pinaster could be 200 ha. Therefore, you need to create a pilot inventory and measure a variable such as basal area maybe in 5 pilot plots of P. sylvestris and 7 pilot plots of P. pinaster. With that data collected, you can use three stratified sample size methods:
Optimal Allocation with Constant Cost: using method = 'optimal'. The sampling units
are distributed within the different strata taking into account the size (e.g. 100 ha vs 200
ha) and the heterogeinity (e.g. differences in basal area). It minimizes the number of
sampling units.
Optimal Allocation with Variable Cost: using method = 'cost'. This method needs to know
the cost of a sampling unit in each strata. It will minimize the cost of the inventory,
taking into account the size, the heterogeinity, and the cost of the sampling unit of the strata.
Proportional Allocation: using method = 'prop'. The sampling units are distributed
proportional to the size of the strata. In the example, 33% of the estimated sampling
units will be allocated to P. sylvestris and 66% to P. pinaster.
Where:
n: estimated sample size
t: the value of student's t
: proportion of pilot plots of strata
: standard deviation of x
: variance of x
N: population size (number of plots of plot_size that fit in total_area)
: maximum allowed absolute error. Calculated from x and max_error
N: the size of the pilot inventory
S7 StratifiedSampleSize object with:
results: data.frame with the main results by stratum
strata_error: data.frame with maximum absolute error C.I (max_abs_error,
x_min, x_max), and the esimator of the typical error C.I (sampling error, x_ci_lo,
x_ci_hi)
sampling_error: data.frame with the maximum absolute error C.I (max_abs_error,
x_min, x_max), and the typical sampling error of the weighted mean C.I (sampling error,
x_ci_lo, x_ci_hi)
sampling_opts: list with function options
## read pilot inventory ficticious data data_path <- system.file("extdata/pilot_inventory.csv", package = "silviculture") inventory_tbl <- read.csv(data_path) ## calculate sample size sample_size_list <- silv_sample_size_stratified( data = inventory_tbl, x = basal_area, strata = stratum, total_area = area, method = "optimal", cost = cost, plot_size = 100, conf_level = .95, max_error = .05 )## read pilot inventory ficticious data data_path <- system.file("extdata/pilot_inventory.csv", package = "silviculture") inventory_tbl <- read.csv(data_path) ## calculate sample size sample_size_list <- silv_sample_size_stratified( data = inventory_tbl, x = basal_area, strata = stratum, total_area = area, method = "optimal", cost = cost, plot_size = 100, conf_level = .95, max_error = .05 )
Returns a data frame with province codes, names, and which SNFI dataset (SNFI4 or SNFI3 fallback) is used for each.
silv_snfi_provinces()silv_snfi_provinces()
A data.frame with columns province_id, province_name, and
snfi_version.
silv_snfi_provinces()silv_snfi_provinces()
Returns a data frame of species codes and names from the SNFI4 species catalogue.
silv_snfi_species(snfi_version = "SNFI4")silv_snfi_species(snfi_version = "SNFI4")
snfi_version |
Character. Either |
A data.frame with columns species_code and species_name.
head(silv_snfi_species()) head(silv_snfi_species("SNFI3"))head(silv_snfi_species()) head(silv_snfi_species("SNFI3"))
Calculates the Hart Index or the Hart-Becking Index for even-aged stands
silv_spacing_index(h0, ntrees, which = "hart")silv_spacing_index(h0, ntrees, which = "hart")
h0 |
Numeric vector with dominant height |
ntrees |
Numeric vector with number of trees of the dominant height per hectare |
which |
A character with the name of the index (either |
The spacing index can be used to determine whether a thinning is needed or not, and also to determine how intense it should be.
Hart Index: it assumes even-aged stands with square planting pattern.
Hart-Brecking Index: it assumes triangular planting pattern.
A numeric vector
Assmann, E. (1970) The principles of forest yield study: Studies in the organic production, structure, increment, and yield of forest stands. Pergamon Press, Oxford.
library(dplyr) ## Calculate spacing index for each plot inventory_samples |> summarise( h0 = silv_dominant_height(diameter, height), ntrees = n(), .by = plot_id ) |> ## calculate number of trees per hectare mutate(ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 14.1)) |> mutate(spacing = silv_spacing_index(h0, ntrees_ha))library(dplyr) ## Calculate spacing index for each plot inventory_samples |> summarise( h0 = silv_dominant_height(diameter, height), ntrees = n(), .by = plot_id ) |> ## calculate number of trees per hectare mutate(ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 14.1)) |> mutate(spacing = silv_spacing_index(h0, ntrees_ha))
silv_sqrmean_diameter(diameter, ntrees = NULL)silv_sqrmean_diameter(diameter, ntrees = NULL)
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
A numeric vector
## calculate dg for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), h0 = silv_dominant_height(dclass, height, ntrees_ha), dg = silv_sqrmean_diameter(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate dg for a vector of diameters silv_sqrmean_diameter(c(12.5, 23.5, 14, 16, 18.5))## calculate dg for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_diametric_class(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10), h0 = silv_dominant_height(dclass, height, ntrees_ha), dg = silv_sqrmean_diameter(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate dg for a vector of diameters silv_sqrmean_diameter(c(12.5, 23.5, 14, 16, 18.5))
Calculates Basal Area in square meters.
silv_stand_basal_area(diameter, ntrees = NULL, units = "cm")silv_stand_basal_area(diameter, ntrees = NULL, units = "cm")
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
units |
The units of the diameter (one of |
The function uses the next formula:
where G is the basal area in , and D is the diameter in cm. If ntrees
in the number of trees per hectare, then the result will be . It is
recommended to use the squared mean diameter calculated with silv_stand_qmean_diameter().
Note that if ntrees = NULL, the output of the function will be exactly
the same as in silv_tree_basal_area().
A numeric vector
## calculate G for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), dg = silv_stand_qmean_diameter(dclass, ntrees_ha), g = silv_stand_basal_area(dclass, ntrees_ha), .by = c(plot_id, species) )## calculate G for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), dg = silv_stand_qmean_diameter(dclass, ntrees_ha), g = silv_stand_basal_area(dclass, ntrees_ha), .by = c(plot_id, species) )
Calculates the dominant diameter using Assman and Friedrich method, or Weise method
silv_stand_dominant_diameter( diameter, ntrees = NULL, which = c("assman", "weise") )silv_stand_dominant_diameter( diameter, ntrees = NULL, which = c("assman", "weise") )
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
which |
The method to calculate the dominant diameter (see details) |
The dominant diameter is the mean diameter of the 100 thickest trees per
hectare. Therefore, diameter and ntrees should be vectors of the same length.
Assman: calculates the as the mean diameter of the 100 thickest
trees per hectare
Weise: calculates the as the quadratic mean diameter of the
20% thickest trees per hectare
A numeric vector
## calculate d0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), d0 = silv_stand_dominant_diameter(dclass, ntrees_ha), .by = c(plot_id, species) )## calculate d0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), d0 = silv_stand_dominant_diameter(dclass, ntrees_ha), .by = c(plot_id, species) )
Calculates the dominant height using the Assman equation or the Hart equation
silv_stand_dominant_height( diameter, height, ntrees = NULL, which = c("assman", "hart") )silv_stand_dominant_height( diameter, height, ntrees = NULL, which = c("assman", "hart") )
diameter |
Numeric vector of diameters or diameter classes |
height |
Numeric vector of tree heights |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
which |
The method to calculate the dominant height (see details) |
The dominant height is the mean height of dominant trees, which is
less affected than overall mean height by thinning or other treatments.
Assman: calculates the as the mean height of the 100 thickest
trees per hectare
Hart: calculates the as the mean height of the 100 tallest
trees per hectare
When ntrees = NULL, the function will assume that each diameter and height
belongs to only one tree. If you have data aggregated by hectare, you'll use the
number of trees per hectare in this argument.
A numeric vector
Assmann, E. (1970) The principles of forest yield study: Studies in the organic production, structure, increment, and yield of forest stands. Pergamon Press, Oxford.
## calculate h0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), h0 = silv_stand_dominant_height(dclass, height, ntrees_ha), .by = c(plot_id, species) )## calculate h0 for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), h0 = silv_stand_dominant_height(dclass, height, ntrees_ha), .by = c(plot_id, species) )
Tree's mean height weighted by basal area
silv_stand_lorey_height(height, g, ntrees = NULL)silv_stand_lorey_height(height, g, ntrees = NULL)
height |
Numeric vector of tree heights |
g |
Numeric vector of basal areas |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
The function calculates Lorey's mean height according to:
When ntrees is not provided (i.e. ntrees = NULL) the formula is simply
the weighted mean of the provided heights and basal areas:
A numeric vector
## Calculate Lorey's Height by plot and species library(dplyr) inventory_samples |> mutate(g = silv_tree_basal_area(diameter)) |> summarise( lh = silv_stand_lorey_height(height, g), .by = c(plot_id, species) )## Calculate Lorey's Height by plot and species library(dplyr) inventory_samples |> mutate(g = silv_tree_basal_area(diameter)) |> summarise( lh = silv_stand_lorey_height(height, g), .by = c(plot_id, species) )
Calculates the quadratic mean diameter (QMD)
silv_stand_qmean_diameter(diameter, ntrees = NULL)silv_stand_qmean_diameter(diameter, ntrees = NULL)
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
A numeric vector
## calculate dg for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), h0 = silv_stand_dominant_height(dclass, height, ntrees_ha), dg = silv_stand_qmean_diameter(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate dg for a vector of diameters silv_stand_qmean_diameter(c(12.5, 23.5, 14, 16, 18.5))## calculate dg for inventory data grouped by plot_id and species library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter)) |> summarise( height = mean(height, na.rm = TRUE), ntrees = n(), .by = c(plot_id, species, dclass) ) |> mutate( ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10), h0 = silv_stand_dominant_height(dclass, height, ntrees_ha), dg = silv_stand_qmean_diameter(dclass, ntrees_ha), .by = c(plot_id, species) ) ## calculate dg for a vector of diameters silv_stand_qmean_diameter(c(12.5, 23.5, 14, 16, 18.5))
Summarize forest inventory data calculating most typical variables
silv_summary( data, diameter, height, plot_size, .groups = NULL, plot_shape = "circular", dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, which_h0 = "assman", which_spacing = "hart" )silv_summary( data, diameter, height, plot_size, .groups = NULL, plot_shape = "circular", dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, which_h0 = "assman", which_spacing = "hart" )
data |
A tibble of inventory data |
diameter |
Numeric vector of diameters or diameter classes |
height |
Numeric vector of tree heights |
plot_size |
The size of the plot. See |
.groups |
A character vector with variables to group by (e.g. plot id, tree species, etc) |
plot_shape |
The shape of the sampling plot. Either |
dmin |
The minimum inventory diameter in centimeters |
dmax |
The maximum inventory diameter in centimeters. Values that
are greater than |
class_length |
The length of the class in centimeters |
include_lowest |
Logical. If TRUE (the default), the intervals are
[dim1, dim2) |
which_h0 |
The method to calculate the dominant height. See |
which_spacing |
A character with the name of the index (either |
The function calculates many inventory parameters and returns two tibbles:
dclass_metrics: metrics summarized by .groups and diametric classes
group_metrics: metrics summarized by .groups
an S7 Inventory list with 2 tibbles
silv_summary( data = inventory_samples, diameter = diameter, height = height, plot_size = 10, .groups = c("plot_id", "species") )silv_summary( data = inventory_samples, diameter = diameter, height = height, plot_size = 10, .groups = c("plot_id", "species") )
Calculates thinning schemes for forest management by selecting trees to extract based on specified criteria. Supports both thinning from below (removing smaller trees) and thinning from above (removing larger trees) approaches.
silv_treatment_thinning( data, var, diameter, ntrees, thinning = c("below", "above"), perc = 0.3, .groups = NULL )silv_treatment_thinning( data, var, diameter, ntrees, thinning = c("below", "above"), perc = 0.3, .groups = NULL )
data |
A data frame, or silviculture::Inventory object. See details. |
var |
A variable used for calculating the thinning. Typically used variables basal area, number of trees, or volume |
diameter |
Numeric vector of diameters or diameter classes |
ntrees |
Numeric vector with number of trees of the diameter class per
hectare. If |
thinning |
Charater string specifying the thinning type. Available options
are |
perc |
Numeric value between 0 and 1 specifying the percentage of |
.groups |
A character vector with variables to group by (e.g. plot id, tree
species, etc). Ignored when using a |
This function implements common silvicultural thinning practices:
Thinning from below: Removes trees with the lowest values of the specified variable. This approach typically removes suppressed, damaged, or poor-quality trees, mimicking natural mortality processes.
Thinning from above: Removes trees with the highest values of the specified variable. This approach harvests the most valuable trees while leaving smaller trees to continue growing.
The function calculates which trees to extract based on the ranking of the specified variable and the desired thinning percentage. When grouping variables are provided, thinning is calculated separately for each group.
Using a silviculture::Inventory object
The result of silv_summary() can be used as the data argument. If so, the .groups
will be taken from this object, and it will keep the previous data in a new S7 object.
A silviculture::Thinning object with three items:
data: the input data with two new columns
group_metrics: it will include the data from the silviculture::Inventory object
thinning_opts: options used for S7 methods
# Get summary of inventory data inventory <- inventory_samples |> silv_summary( diameter = diameter, height = height, plot_size = 25, .groups = c('plot_id', 'species') ) ## Thinning from below removing 30% of trees based on basal area silv_treatment_thinning( data = inventory, var = g_ha, diameter = dclass, ntrees = ntrees_ha, thinning = "below", perc = 0.3 ) ## Thinning from above removing 20% of trees based on basal area silv_treatment_thinning( data = inventory, var = g_ha, diameter = dclass, ntrees = ntrees_ha, thinning = "above", perc = 0.2 )# Get summary of inventory data inventory <- inventory_samples |> silv_summary( diameter = diameter, height = height, plot_size = 25, .groups = c('plot_id', 'species') ) ## Thinning from below removing 30% of trees based on basal area silv_treatment_thinning( data = inventory, var = g_ha, diameter = dclass, ntrees = ntrees_ha, thinning = "below", perc = 0.3 ) ## Thinning from above removing 20% of trees based on basal area silv_treatment_thinning( data = inventory, var = g_ha, diameter = dclass, ntrees = ntrees_ha, thinning = "above", perc = 0.2 )
Calculates Basal Area in square meters.
silv_tree_basal_area(diameter, units = "cm")silv_tree_basal_area(diameter, units = "cm")
diameter |
Numeric vector of diameters or diameter classes |
units |
The units of the diameter (one of |
The function uses the next formula:
where g is the basal area in of one tree, and D is the diameter in cm.
If you want to calculate the basal area for a group of trees (e.g. per hectares),
please use silv_stand_basal_area()
A numeric vector
## calculate individual basal area silv_tree_basal_area(c(23, 11, 43.5, 94))## calculate individual basal area silv_tree_basal_area(c(23, 11, 43.5, 94))
Classifies the measured diameters into classes of a specified length
silv_tree_dclass( diameter, dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, return_intervals = FALSE )silv_tree_dclass( diameter, dmin = 7.5, dmax = NULL, class_length = 5, include_lowest = TRUE, return_intervals = FALSE )
diameter |
Numeric vector of diameters or diameter classes |
dmin |
The minimum inventory diameter in centimeters |
dmax |
The maximum inventory diameter in centimeters. Values that
are greater than |
class_length |
The length of the class in centimeters |
include_lowest |
Logical. If TRUE (the default), the intervals are
[dim1, dim2) |
return_intervals |
If FALSE, it returns the intervals. Otherwise (the default), it returns the class center |
A numeric vector
library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter))library(dplyr) inventory_samples |> mutate(dclass = silv_tree_dclass(diameter))
This function calculates the volume of a tree or logs using different formulas: Pressler, Huber, Smalian, and Newton. The appropriate diameter and height parameters must be provided depending on the selected formula.
silv_tree_volume( diameter_base = NULL, diameter_top = NULL, diameter_center = NULL, diameter = NULL, height = NULL, formula = "pressler", ntrees = NULL )silv_tree_volume( diameter_base = NULL, diameter_top = NULL, diameter_center = NULL, diameter = NULL, height = NULL, formula = "pressler", ntrees = NULL )
diameter_base |
A numeric vector. The diameter at the base of the tree (required for Pressler, Smalian, and Newton formulas). |
diameter_top |
A numeric vector. The diameter at the top of the tree (required for Smalian and Newton formulas). |
diameter_center |
A numeric vector. The diameter at the center of the tree (required for Huber and Newton formulas). |
diameter |
A numeric vector. The diameter at breast height (used in
Pressler formula if provided instead of |
height |
A numeric vector. The tree or log height (required for all formulas). |
formula |
Character. The volume formula to use. Options: |
ntrees |
A numeric vector with number of trees of the same dimensions. Default is 1. |
A numeric value representing the tree volume.
silv_tree_volume(diameter_base = 30, height = 20, formula = "pressler") silv_tree_volume(diameter_center = 25, height = 15, formula = "huber") silv_tree_volume(diameter_base = 30, diameter_top = 20, height = 20, formula = "smalian")silv_tree_volume(diameter_base = 30, height = 20, formula = "pressler") silv_tree_volume(diameter_center = 25, height = 15, formula = "huber") silv_tree_volume(diameter_base = 30, diameter_top = 20, height = 20, formula = "smalian")
This function calculates the volume of a tree or logs using different formulas: Pressler, Huber, Smalian, and Newton. The appropriate diameter and height parameters must be provided depending on the selected formula.
silv_volume( diameter_base = NULL, diameter_top = NULL, diameter_center = NULL, diameter = NULL, height = NULL, formula = "pressler", ntrees = NULL )silv_volume( diameter_base = NULL, diameter_top = NULL, diameter_center = NULL, diameter = NULL, height = NULL, formula = "pressler", ntrees = NULL )
diameter_base |
A numeric vector. The diameter at the base of the tree (required for Pressler, Smalian, and Newton formulas). |
diameter_top |
A numeric vector. The diameter at the top of the tree (required for Smalian and Newton formulas). |
diameter_center |
A numeric vector. The diameter at the center of the tree (required for Huber and Newton formulas). |
diameter |
A numeric vector. The diameter at breast height (used in
Pressler formula if provided instead of |
height |
A numeric vector. The tree or log height (required for all formulas). |
formula |
Character. The volume formula to use. Options: |
ntrees |
A numeric vector with number of trees of the same dimensions. Default is 1. |
A numeric value representing the tree volume.
silv_volume(diameter_base = 30, height = 20, formula = "pressler") silv_volume(diameter_center = 25, height = 15, formula = "huber") silv_volume(diameter_base = 30, diameter_top = 20, height = 20, formula = "smalian")silv_volume(diameter_base = 30, height = 20, formula = "pressler") silv_volume(diameter_center = 25, height = 15, formula = "huber") silv_volume(diameter_base = 30, diameter_top = 20, height = 20, formula = "smalian")
Allometric equation coefficients for tree volume and increment from the 3rd Spanish National Forest Inventory (SNFI3/IFN3), as documented by MITECO.
snfi3_volume_coefficientssnfi3_volume_coefficients
A tibble with 37,730 rows and 16 variables:
Integer. Province numeric code.
Character. Province name.
Integer. Species numeric code.
Character. Species scientific name.
Character. Volume component: VCC (merchantable volume with bark), VSC (merchantable volume without bark), IAVC (annual volume increment with bark), or VLE (coarse firewood volume).
Integer. Tree quality class (calidad del árbol), from 1 (healthy and straight tree) to 6 (dead tree).
Character. Special parameter metadata.
Integer. Equation model index.
Numeric. Equation coefficients (NA where not applicable).
Numeric. Coefficient of determination of the model.
MITECO. 3rd Spanish National Forest Inventory - SIG database codes. https://www.miteco.gob.es/content/dam/miteco/es/biodiversidad/servicios/banco-datos-naturaleza/documentador_bdcampo_ifn3_tcm30-282240.pdf
Allometric equation coefficients for tree volume and increment from the 4th Spanish National Forest Inventory (SNFI4/IFN4), as documented by MITECO.
snfi4_volume_coefficientssnfi4_volume_coefficients
A tibble with 20,925 rows and 15 variables:
Integer. Province numeric code.
Character. Province name.
Integer. Species numeric code.
Character. Species scientific name.
Character. Volume component: VCC (merchantable volume with bark), VSC (merchantable volume without bark), IAVC (annual volume increment with bark), or VLE (coarse firewood volume).
Integer. Tree quality class (calidad del árbol), from 1 (healthy and straight tree) to 6 (dead tree).
Integer. Equation model index.
Numeric. Equation coefficients (NA where not applicable).
Character. Mean plot diameter metadata (diámetro normal medio), required for IAVC equation model 13.
MITECO. 4th Spanish National Forest Inventory - SIG database codes. https://www.miteco.gob.es/content/dam/miteco/es/biodiversidad/temas/inventarios-nacionales/documentador_sig_tcm30-536622.pdf