Package 'OxSR'

Title: Soil Iron Oxides via Diffuse Reflectance
Description: Calculate the ratio of iron oxides, hematite and goethite, in soil using the diffuse reflectance technique. The Kubelka-Munk theory, second derivative analysis, and spectral region amplitudes related to hematite and goethite content are used for quantification (Torrent, J., & Barron, V. (2008) <doi:10.2136/sssabookser5.5.c13>). Additionally, the package calculates soil color in the visible spectrum using Munsell and RGB color spaces, based on color theory (Viscarra et al. (2006) <doi:10.1016/j.geoderma.2005.07.017>).
Authors: Gustavo Frosi [aut, cre] , Vidal Barrón [aut] , Alberto Inda [aut] , Kayn Bastiani [aut]
Maintainer: Gustavo Frosi <[email protected]>
License: AGPL (>= 3)
Version: 1.0.1
Built: 2025-03-17 12:30:21 UTC
Source: https://github.com/fgu5tav0/oxsr

Help Index


Organize Cary data

Description

Cleans the raw data extracted from the Cary 5000 UV-Vis-IR spectrophotometer, ensuring an organized dataset for analysis. During the process, duplicate columns containing wavelength are removed to avoid redundancy. Samples with missing data are also eliminated, ensuring that only complete measurements are retained. Additionally, the columns are reordered based on the sample names, making it easier to interpret and manipulate the data. The wavelength column is placed as the first column, followed by the sample columns.

Usage

clean_sheet_cary(
  data = data,
  prefix = NULL,
  name_wave = "Wave",
  range_wave = c(380, 2500),
  nm_step = 0.5
)

Arguments

data

A data.frame containing the wavelength and reflectance values. It should be obtained directly from the export of a CSV file.

prefix

Indicates the prefix for columns where there is no sample. It is usually predefined as x or ..

name_wave

Indicates the name of the wavelength column. The default is 'wave'.

range_wave

Is the wavelength range used. The default is from 380 nm to 2500 nm.

nm_step

The increment in nanometers between consecutive wavelength readings. This defines the resolution of the measurements. The default value is 0.5 nm.

Value

Returns an organized data.frame

Examples

# example code
library(OxSR)
data(data_cary)

clean_sheet_cary(data_cary, prefix = "x")

# With pipe

data_cary |> clean_sheet_cary(prefix = "x")

Diffuse soil reflectance via Cary equipment

Description

A dataset containing diffuse reflectance measurements of soil samples from Brazil. The data were obtained using a Cary 5000 UV-Vis-NIR spectrophotometer, covering the spectral range from 2500 nm to 380 nm with a reading interval of 0.5 nm (Frosi et al., 2025).

Usage

data_cary

Format

A data frame with 5,417 rows and 52 columns:

a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a26

Wavelength values in nanometers for each sample (labeled "a"). Each column represents the wavelength for a specific sample.

x2, x4, x6, x8, x10, x12, x14, x16, x18, x20, x22, x24, x26, x28, x30, x32, x34, x36, x38, x40, x42, x44, x46, x48, x50

Reflectance percentage (%R) corresponding to each wavelength for the same sample. The "x" columns represent the reflectance values for the corresponding "a" sample columns.

References

Frosi, G., Inda, A., & Barrón, V. (2025). Diffuse reflectance of soils from Brazil Data set. Zenodo. doi:10.5281/zenodo.14879041


Ratios Hm/(Hm+Gt)

Description

Calculates the relationship between the iron oxides hematite and goethite in soil sample:

Hm/Gt=hematitehematite+goethiteHm/Gt = \frac{\text{hematite}}{\text{hematite} + \text{goethite}}

based on the soil's diffuse reflectance curve in the visible spectrum, the Kubelka-Munk equation, and the second derivative (Scheinost et al., 1998; Torrent et al., 2008).

Usage

relation_hm_gt(
  data = data,
  points_smoothing = 0.3,
  hm_gt_limits = list(hm = c(535, 585), gt = c(430, 460)),
  pv_tolerance = c(0, 0, 0, 0),
  name_wave = "wave",
  plot = FALSE
)

Arguments

data

A data.frame containing the input data, where the first column should be the wavelength and the remaining columns should contain the reflectance data of the sample.

points_smoothing

The number of points used for smoothing the data to reduce noise in the spectral readings. The default value is 0.3.

hm_gt_limits

A list containing the detection range values for hematite (hm) and goethite (gt). The default is list(hm = c(535, 585), gt = c(430, 460)).

pv_tolerance

A numeric vector with 4 elements, each corresponding to one of the limits for hematite (hm) and goethite (gt). This value specifies the tolerance for the point values in the calculation, helping to account for small variations in the data and controlling the precision of the calculation.

name_wave

The name of the wavelength column in the data. By default, it is set to 'wave'.

plot

A logical value indicating whether to generate a plot of the results. If set to TRUE, a plot will be displayed; if FALSE, no plot will be shown.

Value

a data.frame with each sample in the rows and columns containing the minimum, maximum, and amplitude for Hm and Gt, along with the Hm/Gt ratio.

References

Scheinost, A. C., Chavernas, A., Barrón, V., & Torrent, J. (1998). Use and limitations of second-derivative diffuse reflectance spectroscopy in the visible to near-infrared range to identify and quantify Fe oxide minerals in soil. Clays and Clay Minerals, 46(5), 528–536. doi:10.1346/CCMN.1998.0460506

Torrent, J., & Barron, V. (2008). Diffuse Reflectance Spectroscopy. Methods of Soil Analysis, 5, 367–385. doi:10.2136/sssabookser5.5.c13

Examples

# example code
library(OxSR)
data(data_cary)

data_clean <- clean_sheet_cary(data_cary, prefix = "x")

relation_hm_gt(data_clean)

# With plot
relation_hm_gt(data_clean[,1:2], plot = TRUE)

Soil color by diffuse reflectance

Description

The function converts the visible soil spectrum to three-dimensional color systems, such as Munsell and RGB, using the CIE tristimulus values for the conversion. This allows for the standardized representation of colors and facilitates visual and comparative analysis.

Usage

soil_color(data = data,
           name_wave = "wave",
           tri_values = "std",
           plot = FALSE)

Arguments

data

A data.frame containing the wavelength and reflectance values.

name_wave

Character indicating the name of the column with the wavelength. It can be only the initial characters.

tri_values

Tristimulus Values. Values from the colorSpec package can be used.

plot

Logical, if TRUE, the plot with the colors is generated, the default is FALSE

Value

A data.frame with color values in Munsell, HVC, RGB, and ⁠hexadecimal code⁠.

Examples

# example code
data(soil_refle)

soil_color(soil_refle)

# tristimulus values {colorSpec}
soil_color(soil_refle, tri_values = "xyz1931.1nm", plot = TRUE)

Diffuse reflectance of soils from Brazil

Description

A cleaned and organized diffuse reflectance database. The structure of the database includes the first column as the wavelength used in all samples, with the remaining columns representing the soil samples (Frosi et al., 2025).

Usage

soil_refle

Format

A data frame with 4241 rows and 24 columns:

wavelength_nm

Wavelength values in nanometers.

a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a22, a24, a26

Reflectance percentage (%R) corresponding to each for each soil sample.

References

Frosi, G., Inda, A., & Barrón, V. (2025). Diffuse reflectance of soils from Brazil Data set. Zenodo doi:10.5281/zenodo.14879041