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

blue-carbon bluecarbon carbon ecology r-package

Keywords from Contributors

marine-data seagrass

Last synced: about 19 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-universe version](https://ecologyr.r-universe.dev/BlueCarbon/badges/version)](https://ecologyr.r-universe.dev/BlueCarbon) [![r-universe status](https://ecologyr.r-universe.dev/BlueCarbon/badges/checks)](https://ecologyr.r-universe.dev/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")` [![DOI](https://joss.theoj.org/papers/10.21105/joss.08333/status.svg)](https://doi.org/10.21105/joss.08333) [![](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.
Following the protocols published by the Blue Carbon initiative [Howard et al. (2014)](https://www.cifor-icraf.org/knowledge/publication/5095/).

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="527"}

#### ***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="429"}

#### ***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 was estimated before compaction correction, it can be provided as a variable and the function will correct it accordingly.

#### ***estimate_oc*** **- Organic carbon % estimation from organic matter %**

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. (2025)](https://doi.org/10.1038/s43247-025-02390-2) 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="486"}

#### ***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)).
Therefore, this function will always provide either a estimated stock (if the core reaches the desired depth) or a predicted stock (if not).
However, if the max depth of the core and the desired depth differ greatly, this predicted depth could differ greatly from the real stock.
We recommend that, if possible, the users use the function `test_extrapolation()` to assess the error of this extrapolation, and that they clearly indicate the maximum depth of the cores in the methods section of the resulting research outputs.

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

#### ***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:

Piñeiro-Juncal et al., (2025). BlueCarbon R package: Estimation of Organic Carbon Stocks and Sequestration Rates From Soil Core Data. Journal of Open Source Software, 10(115), 8333, 

A BibTeX entry for LaTeX users is

```{verbatim}
@article{Piñeiro-Juncal2025,
  doi = {10.21105/joss.08333},
  url = {https://doi.org/10.21105/joss.08333},
  year = {2025},
  publisher = {The Open Journal},
  volume = {10},
  number = {115},
  pages = {8333},
  author = {Piñeiro-Juncal, Nerea and Astigarraga, Julen and Costa, Valentina and Martins, Márcio and Rodríguez-Sánchez, Francisco},
  title = {BlueCarbon R package: Estimation of Organic Carbon Stocks and Sequestration Rates From Soil Core Data},
  journal = {Journal of Open Source Software}
}
```



## 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://ecologyr.github.io/workshop/man/figures/logos.png)

        

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
- family-names: Piñeiro-Juncal
  given-names: Nerea
  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: Márcio
  orcid: "https://orcid.org/0000-0002-6969-2215"
- family-names: Rodríguez-Sánchez
  given-names: Francisco
  orcid: "https://orcid.org/0000-0002-7981-1599"
doi: 10.5281/zenodo.17521760
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Piñeiro-Juncal
    given-names: Nerea
    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: Márcio
    orcid: "https://orcid.org/0000-0002-6969-2215"
  - family-names: Rodríguez-Sánchez
    given-names: Francisco
    orcid: "https://orcid.org/0000-0002-7981-1599"
  date-published: 2025-11-25
  doi: 10.21105/joss.08333
  issn: 2475-9066
  issue: 115
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 8333
  title: "BlueCarbon R package: Estimation of Organic Carbon Stocks and
    Sequestration Rates From Soil Core Data"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.08333"
  volume: 10
title: "BlueCarbon R package: Estimation of Organic Carbon Stocks and
  Sequestration Rates From Soil Core Data"



Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 2 days ago

Total Commits: 326
Total Committers: 9
Avg Commits per committer: 36.222
Development Distribution Score (DDS): 0.555

Commits in past year: 110
Committers in past year: 5
Avg Commits per committer in past year: 22.0
Development Distribution Score (DDS) in past year: 0.436

Name Email Commits
NPJuncal n****l@g****m 145
Francisco Rodriguez-Sanchez f****c@g****m 98
NPJuncal n****l@g****m 43
Julen Astigarraga j****a@g****m 14
dependabot[bot] 4****] 8
github-actions[bot] 4****] 7
Saras Windecker s****r 4
MarcioFCMartins m****d@g****m 4
costavale v****a@h****m 3

Issue and Pull Request metadata

Last synced: 10 days ago

Total issues: 52
Total pull requests: 8
Average time to close issues: 4 months
Average time to close pull requests: 3 days
Total issue authors: 5
Total pull request authors: 5
Average comments per issue: 1.73
Average comments per pull request: 0.63
Merged pull request: 8
Bot issues: 0
Bot pull requests: 2

Past year issues: 15
Past year pull requests: 3
Past year average time to close issues: about 1 month
Past year average time to close pull requests: about 7 hours
Past year issue authors: 3
Past year pull request authors: 2
Past year average comments per issue: 0.87
Past year average comments per pull request: 0.0
Past year merged pull request: 3
Past year bot issues: 0
Past year bot pull requests: 2

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

Top Issue Authors

  • NPJuncal (32)
  • smwindecker (9)
  • Pakillo (8)
  • Tania-Maxwell (2)
  • Julenasti (1)

Top Pull Request Authors

  • Julenasti (3)
  • dependabot[bot] (2)
  • Pakillo (1)
  • smwindecker (1)
  • NPJuncal (1)

Top Issue Labels

  • enhancement (12)
  • bug (8)
  • question (3)
  • invalid (2)
  • good first issue (1)
  • documentation (1)

Top Pull Request Labels

  • dependencies (2)
  • github_actions (2)

Package metadata

proxy.golang.org: github.com/ecologyr/bluecarbon

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/ecologyr/bluecarbon#section-documentation
  • Licenses: gpl-3.0
  • Latest release: v0.1.1 (published about 2 months ago)
  • Last Synced: 2025-12-20T00:05:24.028Z (6 days ago)
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.111%
    • Average: 5.282%
    • Dependent repos count: 5.454%
proxy.golang.org: github.com/EcologyR/BlueCarbon

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/EcologyR/BlueCarbon#section-documentation
  • Licenses: gpl-3.0
  • Latest release: v0.1.1 (published about 2 months ago)
  • Last Synced: 2025-12-20T00:05:25.773Z (6 days ago)
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.111%
    • Average: 5.282%
    • Dependent repos count: 5.454%
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.1 (published about 2 months ago)
  • Last Synced: 2025-12-20T00:05:24.353Z (6 days ago)
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 173 Last month
  • Rankings:
    • Dependent packages count: 27.154%
    • Dependent repos count: 33.449%
    • Average: 49.215%
    • Downloads: 87.043%
  • Maintainers (1)

Score: 9.75417514934912