# SimpleESM: R script to calculate soil organic carbon and nitrogen stocks at Equivalent Soil Mass

Fabien Ferchaud, Florent Chlebowski, Bruno Mary

► To cite this version:

Fabien Ferchaud, Florent Chlebowski, Bruno Mary. SimpleESM: R script to calculate soil organic carbon and nitrogen stocks at Equivalent Soil Mass. Institut National de Recherche pour l'Agriculture, l'Alimentation et l'Environnement (INRAE). 2023. hal-04013158v2

HAL Id: hal-04013158

https://hal.science/hal-04013158v2

Submitted on 10 Oct 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
SimpleESM:

R script to calculate soil organic carbon and
nitrogen stocks at Equivalent Soil Mass

Fabien Ferchaud
Florent Chlebowski
Bruno Mary

March 2023
* To cite this document:

Ferchaud F., Chlebowski F. and Mary B. (2023). *SimpleESM: R script to calculate soil organic carbon and nitrogen stocks at Equivalent Soil Mass*. INRAE (France), 9 p.

* Code accessibility:

SimpleESM can be accessed on Github at [https://github.com/fabienferchaud/SimpleESM](https://github.com/fabienferchaud/SimpleESM).

* Contact:

If you have any question, please contact Fabien Ferchaud (INRAE): [fabien.ferchaud@inrae.fr](mailto:fabien.ferchaud@inrae.fr)
Table of contents

<table><tr><td>1</td><td>Why Equivalent Soil Mass (ESM)?</td><td>3</td></tr><tr><td>2</td><td>Principle of calculations</td><td>4</td></tr><tr><td>2.1</td><td>Soil mass per unit area</td><td>4</td></tr><tr><td>2.2</td><td>SOC stock per unit area</td><td>4</td></tr><tr><td>2.3</td><td>Selection of the reference soil mass(es)</td><td>5</td></tr><tr><td>2.4</td><td>Calculations provided by the SimpleESM R script</td><td>5</td></tr><tr><td>3</td><td>Use of the SimpleESM R script</td><td>6</td></tr><tr><td>3.1</td><td>Overview</td><td>6</td></tr><tr><td>3.2</td><td>Requirements</td><td>6</td></tr><tr><td>3.3</td><td>Input data</td><td>6</td></tr><tr><td>3.4</td><td>Options</td><td>7</td></tr><tr><td>3.5</td><td>Running the script</td><td>8</td></tr><tr><td>3.6</td><td>Outputs</td><td>8</td></tr><tr><td colspan="2">References</td><td>9</td></tr></table>
# 1 Why Equivalent Soil Mass (ESM)?

Research questions related to quantification of environmental impacts of agricultural practices often require comparisons of the quantities of elements (e.g. carbon or nitrogen) in the soil (i.e. stocks). Chemical analyses in the laboratory indicate the concentrations of elements in the soil, but the thickness and bulk density of the soil layers in the field must be considered to calculate stocks. To this end, a Fixed Depth method (FD) is commonly used, i.e. stocks are expressed per area over a fixed soil depth. However, when comparing several agricultural practices (e.g. land use change or tillage), related changes in soil bulk density over time and/or between treatments can cause misinterpretation of results. Indeed, when stocks are calculated at FD, a change in bulk density leads to a change in the calculated stock, even without any change in the concentrations (Figure 1). As a solution, the calculation of stocks at “Equivalent Soil Mass” (i.e. the mass of soil in a standard or reference soil layer) has been proposed (Ellert & Bettany, 1995; Lee et al., 2009; Wendt & Hauser, 2013).

<figure><img src="image_2.png" /><figcaption>**Figure1.** Error bias induced by quantifying Soil Organic Carbon (SOC) stocks at fixed depth when differences in bulk density exist (from Wendt & Hauser, 2013).</figcaption></figure>

The R script “SimpleESM” aims to facilitate calculation of stocks at Equivalent Soil Mass (ESM) using concentration and bulk density measurements in multiple soil layers.

**IMPORTANT NOTES:**

1) A central assumption of the ESM approach is that there is no gain or loss of soil mass over time (between two sampling campaigns)<fnref n="1" />. It is therefore not appropriate in case of significant soil erosion.

<footnote n="1">¹ Strictly speaking, it is the mineral soil mass which is stable, but the soil organic matter mass can be considered negligible compared to the total soil mass.</footnote>
2) Since tillage affects the distribution of C inputs in the soil profile, the minimum sampling depth used to compare soil stocks between plots and/or over time should be at least equal to the maximum tillage depth ever realized over time and in all plots.

## 2 Principle of calculations

To calculate the stock of a given element in a soil layer, it is necessary to know the element concentration and the soil mass per unit area. We will use the example of soil organic carbon (SOC) in this document.

### 2.1 Soil mass per unit area

The soil mass for a given layer, $M(z)$ (in t ha⁻¹), can be calculated as the sum of the soil masses of z layers of 1 mm:

$$M(z) = 10 \cdot \sum_{k=1}^{z} \rho(k)$$

where $\rho(k)$ is the bulk density (in g cm⁻³) of the layer k.

The bulk density ($\rho$) is the soil dry mass per unit of soil volume. It can be measured using different methods (e.g. steel cylinders, gamma-densitometer) or calculated from the dry soil mass and the volume of the collected soil cores.

In case of the presence of gravels or pebbles, only the fine earth dry mass (< 2 mm), which corresponds to the fraction used for the chemical analyses, must be considered. Bulk density must therefore be calculated as the fine earth dry mass divided by the total soil volume (Throop et al., 2012; Poeplau et al., 2017).

### 2.2 SOC stock per unit area

The cumulative SOC stock in the layer 0-z ($Q(z)$ in t C ha⁻¹) is calculated as follows:

$$QC(z) = 0.01 \cdot \sum_{k=1}^{z} \rho(k) \cdot C(k)$$

where $C(k)$ is the SOC concentration<fnref n="2" /> in the layer k (in g kg⁻¹).

When using the FD method, the same depth is used for all situations (e.g. treatments and/or all sampling years). Differences in SOC stocks can therefore result from differences in SOC

<footnote n="2">² The SOC concentration is measured on the dry soil, dried at a temperature lower than 40 °C. If the bulk density is obtained for a soil dried at 105 °C, concentration data must be corrected for residual soil moisture, e.g. the difference between soil dried at 35 °C and 105 °C.</footnote>
concentrations and/or differences in bulk density. When using an ESM approach, the soil
depths used for calculations varies and the fixed index is the cumulative soil mass.

To use an ESM method, it is highly recommended to sample multiple layers (at least two). For
example, if someone wants to calculate stocks in a soil layer equivalent to the 0-30 cm layer
of the reference situation, two layers should be sampled (e.g. 0-30 and 30-40 cm) in order to
be able to calculate stocks at ESM in all plots and/or at all dates, without extrapolating outside
the measured range. Furthermore, using rather small depth increments will shorten ESM
interpolation distances and thus decrease the overall error (von Haden *et al.*, 2020).

2.3 Selection of the reference soil mass(es)

When using an ESM method, it is necessary to select one (for one soil layer) or several (for
several soil layers) reference soil mass(es). There is no strict rule to select the reference mass
values, but practical considerations can be taken into account (von Haden *et al.*, 2020). For
example, if soil samples are collected in the same location at multiple time points, the
reference soil mass for a given soil layer can be defined as the average soil mass measured at
time 0. When several treatments are compared at one time, the reference soil mass can be
defined as the average soil mass in the “control” or “baseline” treatment.

## 2.4 Calculations provided by the SimpleESM R script

In the *SimpleESM* R script, stocks are calculated with three different methods:

1) FD: a fixed depth method. SOC stocks are calculated for each sampled soil layer according to the SOC concentration and the bulk density.

2) ESM: a “classical” ESM method (Ellert & Bettany, 1995; Lee *et al.*, 2009). The soil is discretized into elementary layers of 1 mm thickness. For a given sampling location and date (e.g. a given soil core), a soil mass and a SOC concentration is assigned to each elementary layer *k*, depending on the measured layer to which it belongs. Then, the depth of SOC stock calculation (*z*) is determined to get as close as possible to the reference soil mass, *i.e.* additional layers of soil are added, 1 mm at the time, until the reference soil mass is reached. This method has been used previously for example in Autret *et al.* (2016) or Mary *et al.* (2020).

3) ESM2: an “alternative” ESM method based on the “material coordinate system” (McBratney & Minasny, 2010) or “cumulative coordinates approach” (Rovira *et al.*, 2015). Following Wendt & Hauser (2013) or von Haden *et al.* (2020), a cubic spline model is fitted on the relationship between cumulative soil mass and cumulative SOC stock at each sampling location. This model is then used to interpolate the SOC stocks values at the reference soil masses.

The script therefore makes it possible to compare two methods for calculating stocks at ESM
("classical" and "alternative").
# 3 Use of the SimpleESM R script

## 3.1 Overview

SimpleESM can be accessed on Github at https://github.com/fabienferchaud/SimpleESM.

SimpleESM is made of three files:

1) An input Excel file. The one provided at an example is called "Test_SimpleESM.xlsx".

2) A first small R file called "SimpleESM_script.R", which the user can run after setting the different options. This script calls a R function which is in a second file.

3) A second R file called "SimpleESM_function.R" which contains the code of the SimpleESM R function.

## 3.2 Requirements

This R script has been written and tested for R versions ≥ 4.0.0. We also recommend to use R within RStudio.

The Excel file and the two R files must be placed in the R working directory.

The required packages (`readxl`, `tidyr`, `dplyr`, `foreach` and `doParallel`) will be automatically installed and/or loaded when running the script. The last two packages are used to parallelize part of the ESM calculations in order to reduce the execution time.

## 3.3 Input data

The script requires the user to input an Excel file containing at least two sheets:

- "Concentrations", which includes the results of chemical analyses;

- "BD", which includes the bulk density measurements.

A third sheet ("Ref_soil_mass"), containing the reference soil mass(es), is mandatory or optional according to chosen *RefM* option (see Options below).

This file must be placed in the working directory and its name must be indicated in the file "SimpleESM_script.R" at line 11.

The "BD" sheet contains the bulk density values in g cm⁻³ (column `BD_g_cm3`, mandatory). The "Concentrations" sheet contains the SOC concentration values in g kg⁻¹ (column `SOC_g_kg`, mandatory) and optionally the N concentration values in g kg⁻¹ (column `N_g_kg`), the delta ¹³C values in ‰ (column `d13C_per1000`) and the delta ¹⁵N values in ‰ (column `d15N_per1000`).
Each soil sample in the "Concentrations" and "BD" spreadsheets is identified by several columns:

- *Campaign* (mandatory): ID of the sampling campaign;

- *Treatment* (optional): ID of the experimental treatment;

- *Block* (optional): ID of the experimental block;

- *Plot* (mandatory): ID of the sampled plot;

- *Point* (mandatory): ID of the sampled point;

- *Upper_cm* (mandatory): upper depth of the soil sample (in cm, negative value);

- *Lower_cm* (mandatory): lower depth of the soil sample (in cm, negative value).

*Campaign*, *Plot*, *Point*, *Upper_cm* and *Lower_cm* columns are mandatory. If the data originate from several pooled sample points in a given plot, the *Point* column can be filled using the same ID as in the *Plot* column. *Treatment* and *Block* columns are optional but can be useful metadata.

For each sampling point with concentration data, a corresponding point with bulk density values must be provided. The limits of the soil layers can be identical or different between the concentration and the bulk density data. The measurement depth for bulk density must be equal or deeper than the sampling depth for concentrations. The different layers for a given sampling point must be contiguous.

The "Ref_soilaker" sheet contains reference soil mass(es) to be used in the script (when *RefM_option* = "manual"). The columns are (all mandatory):

- *Layer* (layer number from 1 to n);

- *Upper_cm* (upper limit of the soil layer in the reference situation in cm, negative value);

- *Lower_cm* (lower limit of the soil layer in the reference situation in cm, negative value);

- *Ref_soilaker* (reference dry soil mass of the layer, in t ha⁻¹).

## 3.4 Options

The user can choose the name of the output directory (line 14 in "SimpleESM_script.R"). This directory will be automatically created if it does not exist. **Note that if the output files already exist, they will be overwritten each time you execute the SimpleESM R function (and if they are opened during the execution, the script will fail).**

There are three options in the R script:

- *RefM_option*: "manual" or "auto" (line 17 in "SimpleESM_script.R");

- *E_CALC_option*: "SOC_only" or "SOC_and_N" (line 20 in "SimpleESM_script.R");

- *I_CALC_option*: "13C_15N", "13C" or "no" (line 23 in "SimpleESM_script.R").
When `RefM_option` = "manual", the user must provide reference soil mass(es) in the "Ref_soilAKER" sheet of the Excel file.

When `RefM_option` = "auto", the reference soil mass(es) are obtained automatically using the situation with the lowest total cumulative soil mass (this choice makes it possible to calculate stocks at ESM in all situations without extrapolating outside the measured range).

When `E_CALC_OPTION` = "SOC_only", only `SOC_g_kg` is required in the "Concentrations" sheet. When `E_CALC_OPTION` = "SOC_and_N", `SOC_g_kg` and `N_g_kg` must be provided in the "Concentrations" sheet. SOC and N stocks will be calculated, as well as the C:N ratio.

When `L_CALC_OPTION` = "13C_15N", `d13C_per1000` and `d15N_per1000` columns must be provided in the "Concentrations" sheet. The cumulative delta ¹³C and ¹⁵N will be calculated. When `L_CALC_OPTION` = "13C", only `d13C_per1000` is required in the "Concentrations" sheet. When `L_CALC_OPTION` = "no", none of these columns will be used.

## 3.5 Running the script

Once the working directory, the names of the input file and output directory, and the option values have been defined, the user can run the file "SimpleESM_script.R": select all the lines of the script (press Ctrl+A) and click on the Run icon of Rstudio (or press Ctrl+Enter).

The run ends when the message "Results have been saved in [output directory name]" appears in the R console. Alternatively, a warning message ("SimpleESM function has failed due to error(s) listed above") will appear in case of problem(s).

## 3.6 Outputs

Three csv files are generated and saved in the output directory:

- "Output FD.csv" contains the stocks calculated with the FD approach, using the sampled soil depths;

- "Output ESM.csv" contains the stocks and concentrations calculated with the "classical" ESM approach, using the reference soil masses.

- "Output ESM2.csv" contains the stocks and concentrations calculated with the "alternative" ESM approach, using the reference soil masses.

Calculated soil masses, SOC stocks and N stocks are in t ha⁻¹.
• References

Autret, B., Mary, B., Chenu, C., Balabane, M., Girardin, C., Bertrand, M., Grandeau, G., Beaudoin, N., 2016. Alternative arable cropping systems: A key to increase soil organic carbon storage? Results from a 16 year field experiment. *Agric. Ecosyst. Environ.* 232, 150-164.
https://doi.org/10.1016/j.agee.2016.07.008

Ellert, B.H., Bettany, J.R., 1995. Calculation of organic matter and nutrients stored in soils under contrasting management regimes. *Can. J. Soil Sci.* 75, 529-538.
https://doi.org/10.4141/cjss95-075

Lee, J., Hopmans, J.W., Rolston, D.E., Baer, S.G., Six, J., 2009. Determining soil carbon stock changes: Simple bulk density corrections fail. *Agric. Ecosyst. Environ.* 134, 251-256.
https://doi.org/10.1016/j.agee.2009.07.006

Mary, B., Clivot, H., Blaszczyk, N., Labreuche, J., Ferchaud, F., 2020. Soil carbon storage and mineralization rates are affected by carbon inputs rather than physical disturbance: Evidence from a 47-year tillage experiment. *Agric. Ecosyst. Environ.* 299, 106972.
https://doi.org/10.1016/j.agee.2020.106972

McBratney, A.B., Minasny, B., 2010. Comment on "Determining soil carbon stock changes: Simple bulk density corrections fail" [Agric. Ecosyst. Environ. 134 (2009) 251-256]. *Agric. Ecosyst. Environ.* 136, 185-186. https://doi.org/10.1016/j.agee.2009.12.010

Poeplau, C., Vos, C., Don, A., 2017. Soil organic carbon stocks are systematically overestimated by misuse of the parameters bulk density and rock fragment content. SOIL 3, 61-66. https://doi.org/10.5194/soil-3-61-2017

Rovira, P., Sauras, T., Salgado, J., Merino, A., 2015. Towards sound comparisons of soil carbon stocks: A proposal based on the cumulative coordinates approach. *Catena* 133, 420-431. https://doi.org/10.1016/j.catena.2015.05.020

Throop, H.L., Archer, S.R., Monger, H.C., Waltman, S., 2012. When bulk density methods matter: Implications for estimating soil organic carbon pools in rocky soils. *J. Arid. Environ.* 77, 66-71. https://doi.org/10.1016/j.jaridenv.2011.08.020

von Haden, A.C., Yang, W.H., DeLucia, E.H., 2020. Soils' dirty little secret: Depth-based comparisons can be inadequate for quantifying changes in soil organic carbon and other mineral soil properties. *Glob. Change Biol.* 26, 3759-3770. https://doi.org/10.1111/gcb.15124

Wendt, J.W., Hauser, S., 2013. An equivalent soil mass procedure for monitoring soil organic carbon in multiple soil layers. *Eur. J. Soil Sci.* 64, 58-65.
https://doi.org/10.1111/ejss.12002