Skip to contents

OSSL Data

Download and manage Open Soil Spectral Library data

ossl_cache_dir()
Default local cache directory for OSSL data
ossl_download()
Download all three OSSL components (VisNIR, MIR, soillab)
ossl_download_file()
Download one OSSL component file to the cache directory
ossl_join()
Join OSSL spectra with soil lab data for model training
ossl_l1_labels
Fancy display labels for OSSL L1 properties
ossl_l1_properties
All OSSL Level-1 harmonized soil property variable names (34 targets)
ossl_load_raw()
Load a cached OSSL CSV (gzipped) as a data.table
ossl_mir_instruments
MIR instruments contributing to OSSL v1.2
ossl_mir_matrix()
Extract OSSL MIR spectra as a matrix aligned to the OSSL standard grid
ossl_prepare()
Convenience: load and join all OSSL data for a given sensor type
ossl_soillab()
Extract OSSL Level-1 soil lab data for a set of properties
ossl_visnir_instruments
VisNIR instruments contributing to OSSL v1.2
ossl_visnir_matrix()
Extract OSSL VisNIR spectra as a matrix aligned to the OSSL standard grid

Pre-trained Models

Download pre-trained soilVAE models from Zenodo (one-time setup)

download_ossl_models()
Download pre-trained OSSL soilVAE models from Zenodo
models_available()
Check whether pre-trained models are available locally

Model Training

Train soilVAE models on OSSL or custom datasets

build_soilVAE()
Build the soilVAE asymmetric autoencoder model
train_soilVAE()
Train a soilVAE model for a single soil property
train_ossl_models()
Train soilVAE models for all properties of one model family using OSSL data
load_soilVAE()
Load a saved soilVAE model and its scaler
save_scaler()
Save a z-score scaler to RDS and JSON
save_metrics_json()
Save per-model metrics JSON (RMSE, R2, RPIQ, conformal quantiles, latent stats)
metrics_from_y()
Compute prediction metrics (RMSE, R², RPIQ)
split_idx()
Split indices into train / calibration / test sets

In-Memory Model Cache

Load models once per session and reuse them without disk I/O

get_cached_model()
Retrieve a soilVAE model from the in-memory cache
preload_ossl_models()
Pre-load all soilVAE models for a family into memory
list_cached_models()
List models currently held in the in-memory cache
clear_model_cache()
Clear the in-memory model cache

Prediction

Predict soil properties and assess applicability domain

predict_soil()
Predict soil properties from a spectral data frame using soilVAE models
predict_applicability()
Compute applicability-domain scores for new samples
format_predictions()
Round predictions and rename columns to display labels
get_family()
Lookup a model family from the registry
family_matches()
Test whether a family matches a sensor type
property_label()
Get a display label for a soil property key

Preprocessing

Spectral preprocessing functions

preprocess_visnir()
Canonical two-step SG preprocessing for VisNIR (reflectance input)
preprocess_mir()
Canonical two-step SG preprocessing for MIR (absorbance input)
reflectance_to_absorbance()
Convert reflectance to absorbance
apply_pipeline()
Apply a spectral preprocessing pipeline
apply_sg_matrix()
Apply Savitzky-Golay filter row-wise to a spectral matrix
apply_snv()
Apply Standard Normal Variate (SNV) row-wise
parse_sg()
Parse SG parameter string of the form "SG(m,p)", "SG(m,p,d)", etc.
sg_safe_params()
Compute safe SG parameters given available number of columns
resample_to_grid()
Resample a spectral matrix to a target wavelength grid via linear interpolation
get_wavelengths()
Extract wavelength/wavenumber positions from a data frame's column names

Visualization

Plotting functions

plot_spectra()
Plot one or more spectra from a data frame
plot_mean_spectrum()
Plot a mean spectrum with ±1 SD ribbon from a spectral matrix
plot_predictions()
Plot predicted vs observed values for a soil property
plot_applicability()
Plot latent-space applicability domain scores

Registry

Model registry and metadata

model_registry
Official autoSpectra model family registry
ossl_l1_properties
All OSSL Level-1 harmonized soil property variable names (34 targets)
ossl_l1_labels
Fancy display labels for OSSL L1 properties
ossl_visnir_instruments
VisNIR instruments contributing to OSSL v1.2
ossl_mir_instruments
MIR instruments contributing to OSSL v1.2

Shiny App

Launch the interactive application

run_autoSpectra()
Launch the autoSpectra Shiny application

Utilities

Internal helper functions

feature_minmax()
Compute per-band min/max feature range from a preprocessed matrix
dir_create()
Create a directory if it does not already exist
vneed()
Safe shiny::validate wrapper