Learn R Programming

MLSP (version 0.1.0)

merge_of_lab_and_spectrum: Merge Soil Laboratory Data with Spectral Data

Description

This function merges soil laboratory data with cleaned spectral (VNIR) data, performs preprocessing, and prepares inputs for calibration and model building.

Usage

merge_of_lab_and_spectrum(soil_data, data_NaturaSpec_cleaned)

Value

A list with the following elements:

soil

Data frame of soil laboratory data (first 8 columns of merged dataset).

vnir.matrix

Matrix of VNIR spectral reflectance values (without metadata columns).

j

List of calibration sample indices for cross-validation (4 sets).

rm1, rm2, rm3, rm4

Vectors of indices corresponding to spectral bands to be removed (detector artifact regions around 1000 nm and 1800 nm).

ind

Indices of spectral bands used for aggregation (columns 7–2146).

rmove

Indices of bands to be excluded from analysis.

vars

Vector of spectral band names retained after removal.

Arguments

soil_data

A data frame containing soil laboratory measurements (must include a column named LAB_NUM).

data_NaturaSpec_cleaned

A data frame containing cleaned spectral data with columns Wavelength, LAB_NUM, and reflectance values.

Details

The function performs the following steps:

  • Aggregates spectral data by wavelength and computes mean reflectance values.

  • Merges the soil and spectral datasets by LAB_NUM.

  • Separates soil variables and VNIR spectral matrix.

  • Creates calibration sample indices using random sampling.

  • Defines spectral bands to remove (detector artifact areas) and indices to be used in modeling.

Examples

Run this code
# \donttest{
merged <- merge_of_lab_and_spectrum(soil_data, data_NaturaSpec_cleaned)
str(merged)
# }

Run the code above in your browser using DataLab