fgeo.biomass
Calculate biomass with allometric equations from the allodb package and ForestGEO data.
https://github.com/forestgeo/fgeo.biomass
Category: Biosphere
Sub Category: Biomass
Last synced: about 21 hours ago
JSON representation
Repository metadata
Calculate biomass with allometric equations from the allodb package and ForestGEO data
- Host: GitHub
- URL: https://github.com/forestgeo/fgeo.biomass
- Owner: forestgeo
- License: gpl-3.0
- Created: 2018-11-10T13:40:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-23T13:52:44.000Z (over 5 years ago)
- Last Synced: 2025-04-17T20:38:04.718Z (11 days ago)
- Language: R
- Homepage: https://forestgeo.github.io/fgeo.biomass
- Size: 4.16 MB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 10
- Releases: 0
-
Metadata Files:
- Readme: README.Rmd
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
README.Rmd
--- output: github_document editor_options: chunk_output_type: inline --- ```{r, include = FALSE} knitr::opts_chunk$set( cache = TRUE, collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" ) set.seed(1) ``` #Calculate biomass [](https://www.tidyverse.org/lifecycle/#experimental) [](https://travis-ci.org/forestgeo/fgeo.biomass) [](https://coveralls.io/r/forestgeo/fgeo.biomass?branch=master) [](https://cran.r-project.org/package=fgeo.biomass) The goal of fgeo.biomass is to calculate biomass using [ForestGEO](https://forestgeo.si.edu/) data and equations from either the [BIOMASS package](https://CRAN.R-project.org/package=BIOMASS) or the [allodb package](https://forestgeo.github.io/allodb/). * The BIOMASS package is applicable to tropical forests. It was first [published on CRAN in 2016](https://cran.r-project.org/) and on [Methods on Ecology and Evolution in 2017](https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/2041-210X.12753). fgeo.biomass provides the main features of BIOMASS with a simpler interface, consistent with all [fgeo packages](https://forestgeo.github.io/fgeo/). * The allodb package is work in progress, and aims to provide expert-selected allometric equations, both for tropical and temperate forests. fgeo.biomass provides a simple interface to automate the process of finding the right equation(s) for each stem and computing biomass. ## Installation Install the development version of **fgeo.biomass** with: ``` # install.packages("devtools") devtools::install_github("forestgeo/fgeo.biomass") ``` ## Setup In addition to the fgeo.biomass package we will use dplyr and ggplot2 for data wrangling and plotting. ```{r, message=FALSE} library(ggplot2) library(dplyr) library(fgeo.biomass) ``` ## fgeo.biomass wrapping BIOMASS We'll use data from the [Barro Colorado Island, Panama](https://forestgeo.si.edu/sites/neotropics/barro-colorado-island) (BCI). We first pick alive trees and drop missing `dbh` values as we can't calculate biomass for them. ```{r} if (!requireNamespace("bciex", quietly = TRUE)) { stop( "For this example, you must first install the bciex package with:\n", "devtools::install_github('forestgeo/bciex')" ) } bci_tree <- as_tibble(bciex::bci12t7mini) %>% filter(status == "A", !is.na(dbh)) bci_tree ``` We also need species data. ```{r} bci_species <- as_tibble(bciex::bci_species) bci_species ``` `add_tropical_biomass()` adds biomass to your census data. ```{r} biomass <- add_tropical_biomass(bci_tree, bci_species) biomass ``` You may also provide a specific `region` or `latitude` and `longitude`. ```{r} biomass <- add_tropical_biomass( bci_tree, bci_species, latitude = 9.154965, longitude = -79.845884 ) biomass %>% select(biomass, everything()) ``` `propagate_errors()` allows you to propagate errors. ```{r} str( propagate_errors(biomass) ) ``` `model_height()` allows you to create a height model, which you can use to propagate height errors. This is what the entire pipeline looks like: ```{r} model <- model_height(bci_tree) errors <- bci_tree %>% add_tropical_biomass(bci_species) %>% propagate_errors(height_model = model) str(errors) ``` If you pass `latitude` and `longitude` to `add_tropical_biomass(), and then you pass a `height_model` to `propagate_errors()`, then you will need to ignore the coordinates. On an interactive session, you should see something like this:  ```{r} if (interactive()) { errors <- bci_tree %>% add_tropical_biomass( bci_species, latitude = 9.154965, longitude = -79.845884 ) %>% propagate_errors(height_model = model) str(errors) } ``` `add_wood_density()` adds wood density to your census data. It is not limited to tropical forests, and has support for all of these regions: `r glue::glue_collapse(fgeo.biomass:::wd_regions(), sep = ", ", last = ", and ")`. ```{r} wood_density <- add_wood_density(bci_tree, bci_species) wood_density %>% select(starts_with("wd_"), everything()) ``` The BIOMASS package provides a tool to correct taxonomic names. fgeo.biomass does not include that feature. You may use BIOMASS directly or the more focused [taxize package](https://cran.r-project.org/web/packages/taxize/taxize.pdf). ## fgeo.biomass wrapping allodb ## Warning These features are not ready for research. We are now building a [Minimum Viable Product](https://en.wikipedia.org/wiki/Minimum_viable_product), with just enough features to collect feedback from alpha users and redirect our effort. The resulting biomass is still meaningless. We'll use the `add_biomass()` with these inputs: 1. A ForestGEO-like _stem_ or _tree_ table. 2. A _species_ table (internally used to look up the Latin species names from the species codes in the `sp` column of the census table). We'll use data from the [Smithsonian Conservation Biology Institute, USA](https://forestgeo.si.edu/sites/north-america/smithsonian-conservation-biology-institute) (SCBI). We first pick alive trees and drop missing `dbh` values as we can't calculate biomass for them. ```{r} census <- fgeo.biomass::scbi_tree1 %>% filter(status == "A", !is.na(dbh)) census ``` We now use `add_biomass()` to add biomass to our census dataset. ```{r} species <- fgeo.biomass::scbi_species with_biomass <- census %>% add_biomass(species, site = "SCBI") ``` We are warned that we are using a tree-table (as opposed to a stem-table), and informed about how to interpret the resulting `biomass` values for trees and shrubs. Some equations couldn't be found. There may be two reasons: * Some stems in the data belong to species with no matching species in allodb. * Some stems in the data belong to species that do match species in allodb but the available equations were designed for a dbh range that doesn't include actual dbh values in the data. Here are the most interesting columns of the result: ```{r} with_biomass %>% select(treeID, species, biomass) ``` Let's now visualize the relationship between `dbh` and b`biomass` by `species` (black points), in comparison with `agb` (above ground biomass) values calculated with allometric equations for tropical trees (grey points). ```{r, fig.height=14} with_biomass %>% # Convert agb from [Mg] to [kg] mutate(agb_kg = agb * 1e3) %>% ggplot(aes(x = dbh)) + geom_point(aes(y = agb_kg), size = 1.5, color = "grey") + geom_point(aes(y = biomass), size = 1, color = "black") + facet_wrap("species", ncol = 4) + ylab("Reference `agb` (grey) and calculated `biomass` (black) in [kg]") + xlab("dbh [mm]") + theme_bw() ``` Above, the species for which `biomass` couldn't be calculated show no black points, although they do show grey reference-points. To better understand the distribution of `biomass` values for each species we can use a box-plot. ```{r} with_biomass %>% ggplot(aes(species, biomass)) + geom_boxplot() + ylab("biomass [kg]") + coord_flip() ``` For some species the maximum `dbh` for which `biomass` was calculated is much lower than the maximum `dbh` value for which the reference `agb` was calculated. This is because most equations in __allodb__ are defined for a specific range of `dbh` values. Eventually __allodb__ might provide equations beyond the `dbh` limits currently available. To explore this issue, here we use `add_component_biomass()` which allows us to see intermediary results that `add_biomass()` doesn't show. ```{r} detailed_biomass <- suppressWarnings(suppressMessages( add_component_biomass(census, species, site = "SCBI") )) # Maximum `dbh` values by species max_by_species <- detailed_biomass %>% select(species, dbh_max_mm) %>% group_by(species) %>% arrange(desc(dbh_max_mm)) %>% filter(row_number() == 1L) %>% ungroup() # `dbh` is above the maximum limit, so `biomass` is missing (agb has a value) detailed_biomass %>% filter(dbh > 1000) %>% select(-dbh_max_mm) %>% left_join(max_by_species) %>% mutate(agb_kg = agb * 1e3) %>% select(species, biomass, agb, dbh, dbh_max_mm) %>% arrange(species) %>% print(n = Inf) ``` ## Biomass via BIOMASS versus allodb ```{r} temperate_biomass <- add_biomass(census, species, site = "scbi") # Warning: Aplying tropical equations to a temperate forest for comparison tropical_biomass <- add_tropical_biomass(census, species) dbh_biomsss <- tibble( dbh = temperate_biomass$dbh, species = temperate_biomass$species, temperate_biomass = temperate_biomass$biomass, tropical_biomass = tropical_biomass$biomass ) ``` ```{r, fig.height=14} dbh_biomsss %>% ggplot(aes(x = dbh)) + geom_point(aes(y = tropical_biomass), size = 1.5, color = "grey") + geom_point(aes(y = temperate_biomass), size = 1) + facet_wrap("species", ncol = 4) + ylab("Biomass [kg] (via the BIOMASS (grey) and allodb (black) packages)") + xlab("dbh [mm]") + theme_bw() ``` ## General information * [Getting help](SUPPORT.md). * [Contributing](CONTRIBUTING.md). * [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
Owner metadata
- Name: ForestGEO
- Login: forestgeo
- Email: [email protected]
- Kind: organization
- Description: Forest Global Earth Observatory, Smithsonian Institution
- Website: http://www.forestgeo.si.edu/
- Location: Smithsonian Tropical Research Institute
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/25665726?v=4
- Repositories: 7
- Last ynced at: 2023-02-26T20:35:33.242Z
- Profile URL: https://github.com/forestgeo
GitHub Events
Total
Last Year
Committers metadata
Last synced: 7 days ago
Total Commits: 222
Total Committers: 2
Avg Commits per committer: 111.0
Development Distribution Score (DDS): 0.014
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
Mauro Lepore | m****e@g****m | 219 |
Erika Gonzalez-Akre | g****b@s****u | 3 |
Committer domains:
- si.edu: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 29
Total pull requests: 8
Average time to close issues: 29 days
Average time to close pull requests: about 6 hours
Total issue authors: 2
Total pull request authors: 3
Average comments per issue: 2.1
Average comments per pull request: 0.63
Merged pull request: 7
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- maurolepore (28)
- ValentineHerr (1)
Top Pull Request Authors
- maurolepore (4)
- gonzalezeb (3)
- ValentineHerr (1)
Top Issue Labels
- priority low (5)
- feature (5)
- priority high (2)
- refactor (2)
- priority medium (1)
- wip (1)
- needs-review (1)
- docs (1)
- bug (1)
Top Pull Request Labels
Dependencies
- R >= 3.2 depends
- BIOMASS * imports
- allodb >= 0.0.0.9005 imports
- dplyr >= 0.7.8 imports
- fgeo.tool >= 1.2.2 imports
- formatR >= 1.5 imports
- glue >= 1.3.0 imports
- magrittr >= 1.5 imports
- measurements * imports
- memoise >= 1.1.0 imports
- purrr >= 0.3.0 imports
- readr >= 1.3.1 imports
- rlang >= 0.3.1 imports
- stats * imports
- tibble >= 2.0.1 imports
- tidyr >= 0.8.2 imports
- tidyselect * imports
- usethis * imports
- bciex >= 0.0.0.9000 suggests
- covr >= 3.2.1 suggests
- ggplot2 * suggests
- rmarkdown * suggests
- spelling >= 2.0 suggests
- testthat >= 2.0.1 suggests
Score: 3.58351893845611