A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

BlueCarbon

Facilitate the estimation of organic carbon stocks and fluxes from soil/sediment cores from blue carbon ecosystems.
https://github.com/ecologyr/bluecarbon

Category: Emissions
Sub Category: Emission Observation and Modeling

Keywords from Contributors

ecology bluecarbon marine-data seagrass geos control routing virtual transform crop

Last synced: about 23 hours ago
JSON representation

Repository metadata

Estimation of organic carbon stocks and sequestration rates from soil/sediment cores from blue carbon ecosystems

README.Rmd

          ---
output: github_document
editor_options: 
  markdown: 
    wrap: sentence
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# BlueCarbon BlueCarbon website



`r badger::badge_cran_release()` ![](https://img.shields.io/github/r-package/v/EcologyR/BlueCarbon) [![R-CMD-check](https://github.com/EcologyR/BlueCarbon/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/EcologyR/BlueCarbon/actions/workflows/R-CMD-check.yaml) [![codecov](https://codecov.io/gh/EcologyR/BlueCarbon/graph/badge.svg)](https://app.codecov.io/gh/EcologyR/BlueCarbon) 
`r badger::badge_lifecycle("stable")` 
`r badger::badge_repostatus("Active")` 
[![](https://cranlogs.r-pkg.org/badges/grand-total/BlueCarbon)](https://cran.r-project.org/package=BlueCarbon)



The goal of BlueCarbon is to facilitate the estimation of organic carbon stocks and sequestration rates from soil/sediment cores from blue carbon ecosystems.

It includes seven main [functions](https://ecologyr.github.io/BlueCarbon/reference/index.html) to (1) estimate core compaction, (2) correct core compaction, (3) estimate sample thickness, (4) estimate organic carbon content from organic matter content, (5) estimate organic carbon stocks and (6) sequestration rates, and (7) visualize the error in stock extrapolation.

![Blue Carbon package workflow](man/figures/BC_workflow.png){width="569"}

#### ***estimate_compaction*** **- Estimate Core Compaction**

Sampling soil cores by manual percussion often results in the compaction of the material retrieved.
This function (`estimate_compaction()`) estimates the percentage of compaction using measurements taken before and after inserting the corer tube (Fig. 2): the length of the corer tube (sampler_length), distance between the surface of the soil and the top of the tube in the outside (external_distance) and distance between the surface of the soil and the top of the tube in the inside of the tube (internal_distance).

![Soil compaction from field sampling](man/figures/compaction.png){width="364"}

#### ***decompact*** **- Calculate sediment properties after decompaction**

Core compaction derived from field extraction can be mathematically corrected to estimate the original depth of the samples.
This function (`decompact()`) applies a linear correction (assuming uniform compaction of the core material) to adjust the sample depth accurately.
If dry bulk density data is provided, the function also corrects it accordingly.

#### ***estimate_oc*** **- Organic carbon content estimation from organic carbon data**

There is a linear correlation between organic carbon and organic matter content.
This correlation can vary across ecosystems and sampling sites.
This function (`estimate_oc()`) fits a linear regression model between organic matter and organic carbon content of the samples and predicts organic carbon values for samples where the latter information is missing.
Estimation of organic carbon is performed using a linear regression between the logarithm of the organic carbon content and the logarithm of the organic matter content (log(organic carbon) \\\~ log(organic matter)), providing an organic carbon value for each organic matter value.
It fits a model for each sampling station, dominant species, and ecosystem.
If an organic carbon value is already available for a sample, the function returns it.
Otherwise, it applies the model for the corresponding sampling station.
If a model cannot be fitted for that station (e.g. because of limited sample size) or if the model fit is poor, the function instead applies the model for the dominant species.
If no suitable species-level model exists, it then applies the ecosystem-level model.
If no models are available at any of these levels, the function defaults to published models: [Fourqurean et al. (2012)](https://doi.org/10.1038/ngeo1477) for seagrasses, [Maxwell et al. (2023)](https://doi.org/10.1038/s41597-023-02633-x) for salt marshes, and Piñeiro-Juncal et al. for mangroves.
It is unlikely, but possible, that the model predicts higher organic carbon than organic matter content.
If this occurs, the function issues a warning, and it is recommended to discard that model.

#### ***estimate_h*** **- Sample thickness estimation**

For cores where only selected samples were measured, it is necessary to assign a carbon density to the unmeasured sections before estimating the total stock.
This function (`estimate_h()`) identifies gaps between samples and, if any are present, divides the space between the previous and next sample, ensuring continuous samples without gaps in the core (Fig. 3).
The midpoint between two consecutive samples is estimated from the bottom of the previous sample to the top of the next sample, preventing the uneven distribution of gaps between samples with different thickness.
The stock and sequestration rate estimation functions (`estimate_oc_stock()` and `estimate_seq_rate()`) already incorporate this function, so there is no need to run it separately.

![Gap distribution between samples to estimate accumulated organic carbon mass](man/figures/estimate_h.png){width="365"}

#### ***estimate_oc_stock*** **- Organic carbon stock estimation**

Estimates carbon stocks from soil core data down to a specified depth, with 100 as the default.
If the core does not reach the desired depth, the function extrapolates the stock using a linear model based on the relationship between accumulated organic carbon mass and depth.
In this model, accumulated organic carbon mass (stock) is the target variable and depth the explanatory variable (lm(accumulated organic carbon mass \~ depth)).

![Organic carbon stock estimation diagram](man/figures/estimate_stock.png){width="380"}

#### ***test_extrapolation*** **- Visualize the error of stock extrapolation**

This function subset the cores that reach the desired depth, estimates the observed stock, and estimates the stock using the linear model on the relationship between accumulated organic carbon mass and depth.
Extrapolations are performed using the top 90, 75, 50 and 25% length of the specified depth.
The function then compares the observed stock with the extrapolated stock estimates.
Note that this function requires that at least some cores reach the desired depth.

#### ***estimate_seq_rate*** **- Organic carbon sequestration rates estimation**

Estimates the average organic carbon sequestration rate in the soil over a specified time frame (by default 100).
The average sequestration rate is calculated by dividing the stock at the depth corresponding to the target time frame by the length of the time frame itself.

## Installation

BlueCarbon can be installed directly from [CRAN](https://cran.r-project.org/package=BlueCarbon):

``` r
install.packages("BlueCarbon")
```

or from [R-universe](https://ecologyr.r-universe.dev/BlueCarbon):

``` r
install.packages("BlueCarbon", repos = c("https://ecologyr.r-universe.dev", "https://cloud.r-project.org"))
```

Or from [GitHub](https://github.com/EcologyR/BlueCarbon):

``` r
# install.packages("remotes")
remotes::install_github("EcologyR/BlueCarbon")
```

## Citation

If using this package, please cite it:

```{r comment=NA}
citation("BlueCarbon")
```

## Code of Conduct

Please note that the BlueCarbon project is released with a [Contributor Code of Conduct](https://ecologyr.github.io/BlueCarbon/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

## Funding

The development of this software has been funded by Fondo Europeo de Desarrollo Regional (FEDER) and Consejería de Transformación Económica, Industria, Conocimiento y Universidades of Junta de Andalucía (project US-1381388 led by Francisco Rodríguez Sánchez, Universidad de Sevilla).
NPJ was supported by a Juan de la Cierva fellowship (JDC2022-048342-I, MCIN/AEI/10.13039/501100011033, European Union “NextGenerationEU”/PRTR”).
JA acknowledges funding from the CLIMB-FOREST Horizon Europe Project (No 101059888) funded by the European Union.
FRS was supported by VI PPIT-US from Universidad de Sevilla.
MM was supported by a FCT PhD grant (https://doi.org/10.54499/2020.06996.BD).

![](https://ecologyr.github.io/workshop/images/logos.png)

        

Citation (CITATION.cff)

# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
 
cff-version: 1.2.0
message: 'To cite package "BlueCarbon" in publications use:'
type: software
license: GPL-3.0-or-later
title: 'BlueCarbon: Estimation of Organic Carbon Stocks and Sequestration Rates from
  Soil Core Data'
version: 0.1.0
abstract: Tools to estimate soil organic carbon stocks and sequestration rates in
  blue carbon ecosystems. 'BlueCarbon' contains functions to estimate and correct
  for core compaction, estimate sample thickness, estimate organic carbon content
  from organic matter content, estimate organic carbon stocks and sequestration rates,
  and visualize the error of carbon stock extrapolation.
authors:
- family-names: Piñeiro-Juncal
  given-names: Nerea
  email: [email protected]
  orcid: https://orcid.org/0000-0003-3767-1812
- family-names: Astigarraga
  given-names: Julen
  orcid: https://orcid.org/0000-0001-9520-3713
- family-names: Costa
  given-names: Valentina
  orcid: https://orcid.org/0000-0002-1513-0284
- family-names: Martins
  given-names: Marcio
  orcid: https://orcid.org/0000-0002-6969-2215
- family-names: Rodriguez-Sanchez
  given-names: Francisco
  orcid: https://orcid.org/0000-0002-7981-1599
preferred-citation:
  type: manual
  title: 'BlueCarbon: Estimation of Organic Carbon Stocks and Sequestration Rates
    From Soil Core Data'
  authors:
  - family-names: Piñeiro-Juncal
    given-names: Nerea
    email: [email protected]
    orcid: https://orcid.org/0000-0003-3767-1812
  - family-names: Astigarraga
    given-names: Julen
    orcid: https://orcid.org/0000-0001-9520-3713
  - family-names: Costa
    given-names: Valentina
    orcid: https://orcid.org/0000-0002-1513-0284
  - family-names: Martins
    given-names: Marcio
    orcid: https://orcid.org/0000-0002-6969-2215
  - family-names: Rodriguez-Sanchez
    given-names: Francisco
    orcid: https://orcid.org/0000-0002-7981-1599
  year: '2025'
  url: https://github.com/EcologyR/BlueCarbon
  notes: R package version 0.1.0, https://EcologyR.github.io/BlueCarbon/
repository-code: https://github.com/EcologyR/BlueCarbon
url: https://ecologyr.github.io/BlueCarbon/
contact:
- family-names: Piñeiro-Juncal
  given-names: Nerea
  email: [email protected]
  orcid: https://orcid.org/0000-0003-3767-1812
references:
- type: software
  title: 'R: A Language and Environment for Statistical Computing'
  notes: Depends
  url: https://www.R-project.org/
  authors:
  - name: R Core Team
  institution:
    name: R Foundation for Statistical Computing
    address: Vienna, Austria
  year: '2025'
  version: '>= 4.1'
- type: software
  title: covr
  abstract: 'covr: Test Coverage for Packages'
  notes: Suggests
  url: https://covr.r-lib.org
  repository: https://CRAN.R-project.org/package=covr
  authors:
  - family-names: Hester
    given-names: Jim
    email: [email protected]
  year: '2025'
  doi: 10.32614/CRAN.package.covr
- type: software
  title: testthat
  abstract: 'testthat: Unit Testing for R'
  notes: Suggests
  url: https://testthat.r-lib.org
  repository: https://CRAN.R-project.org/package=testthat
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: [email protected]
  year: '2025'
  doi: 10.32614/CRAN.package.testthat
  version: '>= 3.0.0'
- type: software
  title: dplyr
  abstract: 'dplyr: A Grammar of Data Manipulation'
  notes: Imports
  url: https://dplyr.tidyverse.org
  repository: https://CRAN.R-project.org/package=dplyr
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: [email protected]
    orcid: https://orcid.org/0000-0003-4757-117X
  - family-names: François
    given-names: Romain
    orcid: https://orcid.org/0000-0002-2444-4226
  - family-names: Henry
    given-names: Lionel
  - family-names: Müller
    given-names: Kirill
    orcid: https://orcid.org/0000-0002-1416-3412
  - family-names: Vaughan
    given-names: Davis
    email: [email protected]
    orcid: https://orcid.org/0000-0003-4777-038X
  year: '2025'
  doi: 10.32614/CRAN.package.dplyr
- type: software
  title: ggplot2
  abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
  notes: Imports
  url: https://ggplot2.tidyverse.org
  repository: https://CRAN.R-project.org/package=ggplot2
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: [email protected]
    orcid: https://orcid.org/0000-0003-4757-117X
  - family-names: Chang
    given-names: Winston
    orcid: https://orcid.org/0000-0002-1576-2126
  - family-names: Henry
    given-names: Lionel
  - family-names: Pedersen
    given-names: Thomas Lin
    email: [email protected]
    orcid: https://orcid.org/0000-0002-5147-4711
  - family-names: Takahashi
    given-names: Kohske
  - family-names: Wilke
    given-names: Claus
    orcid: https://orcid.org/0000-0002-7470-9261
  - family-names: Woo
    given-names: Kara
    orcid: https://orcid.org/0000-0002-5125-4188
  - family-names: Yutani
    given-names: Hiroaki
    orcid: https://orcid.org/0000-0002-3385-7233
  - family-names: Dunnington
    given-names: Dewey
    orcid: https://orcid.org/0000-0002-9415-4582
  - family-names: Brand
    given-names: Teun
    name-particle: van den
    orcid: https://orcid.org/0000-0002-9335-7468
  year: '2025'
  doi: 10.32614/CRAN.package.ggplot2
- type: software
  title: gridExtra
  abstract: 'gridExtra: Miscellaneous Functions for "Grid" Graphics'
  notes: Imports
  repository: https://CRAN.R-project.org/package=gridExtra
  authors:
  - family-names: Auguie
    given-names: Baptiste
    email: [email protected]
  year: '2025'
  doi: 10.32614/CRAN.package.gridExtra
- type: software
  title: reshape
  abstract: 'reshape: Flexibly Reshape Data'
  notes: Imports
  url: http://had.co.nz/reshape
  repository: https://CRAN.R-project.org/package=reshape
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: [email protected]
  year: '2025'
  doi: 10.32614/CRAN.package.reshape


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 270
Total Committers: 7
Avg Commits per committer: 38.571
Development Distribution Score (DDS): 0.463

Commits in past year: 106
Committers in past year: 5
Avg Commits per committer in past year: 21.2
Development Distribution Score (DDS) in past year: 0.34

Name Email Commits
NPJuncal n****l@g****m 145
Francisco Rodriguez-Sanchez f****c@g****m 80
NPJuncal n****l@g****m 21
Julen Astigarraga j****a@g****m 14
MarcioFCMartins m****d@g****m 4
github-actions[bot] 4****] 3
costavale v****a@h****m 3

Committer domains:


Issue and Pull Request metadata

Last synced: 2 days ago

Total issues: 53
Total pull requests: 11
Average time to close issues: 5 months
Average time to close pull requests: 4 days
Total issue authors: 3
Total pull request authors: 3
Average comments per issue: 2.98
Average comments per pull request: 0.91
Merged pull request: 11
Bot issues: 0
Bot pull requests: 0

Past year issues: 4
Past year pull requests: 0
Past year average time to close issues: 14 days
Past year average time to close pull requests: N/A
Past year issue authors: 1
Past year pull request authors: 0
Past year average comments per issue: 1.5
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

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/ecologyr/bluecarbon

Top Issue Authors

  • NPJuncal (41)
  • Pakillo (11)
  • Julenasti (1)

Top Pull Request Authors

  • Julenasti (7)
  • Pakillo (2)
  • NPJuncal (2)

Top Issue Labels

  • enhancement (18)
  • bug (11)
  • question (6)
  • invalid (2)
  • documentation (1)
  • good first issue (1)

Top Pull Request Labels


Package metadata

cran.r-project.org: BlueCarbon

Estimation of Organic Carbon Stocks and Sequestration Rates from Soil Core Data

  • Homepage: https://github.com/EcologyR/BlueCarbon
  • Documentation: http://cran.r-project.org/web/packages/BlueCarbon/BlueCarbon.pdf
  • Licenses: GPL (≥ 3)
  • Latest release: 0.1.0 (published 2 months ago)
  • Last Synced: 2025-04-26T04:01:29.585Z (2 days ago)
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 198 Last month
  • Rankings:
    • Dependent packages count: 27.154%
    • Dependent repos count: 33.449%
    • Average: 49.215%
    • Downloads: 87.043%
  • Maintainers (1)

Score: 9.436439551116026