
Run the LUCAS Soil 2018 / ESDB WRB benchmark
Source:R/benchmark-lucas-2018.R
benchmark_lucas_2018.RdFor each pedon in pedons, attaches the canonical Reference
Soil Group at its coordinate via lookup_esdb, runs
classify_wrb2022 (or classify_sibcs),
and tabulates predicted vs reference. Optionally fills missing
texture from ISRIC SoilGrids 250m before classifying so that
WRB diagnostic horizons that depend on clay (argic, ferralic,
nitic) are reachable.
Usage
benchmark_lucas_2018(
pedons,
esdb_root,
attribute = "WRBLV1",
fill_texture_from = NULL,
fill_topsoil_from = c("none", "soilgrids", "spectra"),
fill_subsoil_from = c("none", "soilgrids"),
fill_properties = c("clay", "sand", "silt", "phh2o", "soc", "cec", "bdod", "nitrogen",
"cfvo"),
ossl_models = NULL,
classify_with = c("wrb2022", "sibcs"),
max_n = NULL,
soilgrids_lookup_fn = lookup_soilgrids,
verbose = TRUE
)Arguments
- pedons
List of
PedonRecordobjects, typically fromload_lucas_soil_2018.- esdb_root
Path to the unpacked ESDB raster directory (containing the
WRBLV1/sub-folder).- attribute
ESDB attribute to use as reference. Default
"WRBLV1"(Reference Soil Group, 31 codes). Other sensible choices:"FAO90LV1"(legacy FAO 1990).- fill_texture_from
Deprecated alias for
fill_topsoil_from(v0.9.49 signature). When"soilgrids", treated asfill_topsoil_from = "soilgrids"withfill_properties = c("clay", "sand", "silt")andfill_subsoil_from = "none".- fill_topsoil_from
One of
"none"(default),"soilgrids"(fills topsoil 0-20 cm from SoilGrids 250m at 0-5 cm), or"spectra"(runspredict_from_spectrawith the suppliedossl_models; pedons must have$spectra$vnirattached, e.g. viaattach_lucas_spectra).- fill_subsoil_from
One of
"none"(default) or"soilgrids"(synthesises a 30-60 cm B horizon from SoilGrids 250m). Unlocks WRB diagnostic horizons that depend on subsoil features (cambic, argic, mollic).- fill_properties
Character vector of SoilGrids properties to fill when
fill_topsoil_from = "soilgrids"orfill_subsoil_from = "soilgrids". Default uses all 9 properties: clay, sand, silt, phh2o, soc, cec, bdod, nitrogen, cfvo. Set toc("clay", "sand", "silt")to recover the v0.9.49 behaviour.cfvois mapped tocoarse_fragments_pct, which drives the Leptosols diagnostic (>= 90 within 25 cm).- ossl_models
Required when
fill_topsoil_from = "spectra". A list ofsoilKey_pls_modelobjects fromtrain_pls_from_ossl(v0.9.46).- classify_with
One of
"wrb2022"(default) or"sibcs".- max_n
Optional integer cap on the number of pedons benchmarked. Useful for quick development runs.
- soilgrids_lookup_fn
Internal: SoilGrids lookup function (defaults to
lookup_soilgrids). Override for unit tests to inject a deterministic stub.- verbose
If
TRUE(default), prints progress.
Value
A list with elements:
predictionsdata.frame with one row per pedon:
point_id, lon, lat, country, predicted, reference_code, reference_name, agree.confusionConfusion table (predicted vs reference) over in-scope rows.
accuracyOverall fraction of correct classifications among in-scope rows.
per_rsgPer-RSG recall data.frame.
n_in_scopeNumber of pedons with both predicted and reference set.
n_totalTotal pedons benchmarked.
n_errorsNumber of pedons where the classifier errored out.
errorsList of
(i, id, error)tuples for classifier errors.configRecap of arguments used.
Details
This closes Route B of the v0.9.27 EU-LUCAS roadmap end-to-end:
v0.9.44 lookup_esdb provides the reference label;
v0.9.49 (this) provides the loader and the comparison loop;
v0.9.48 lookup_soilgrids fills texture; v0.9.46
predict_from_spectra and v0.9.47
predict_munsell_from_spectra can fill the
chemistry / Munsell gaps when Vis-NIR is available.
Examples
if (FALSE) { # \dontrun{
pedons <- load_lucas_soil_2018(
"soil_data/eu_lucas/LUCAS-SOIL-2018-data-report-readme-v2/LUCAS-SOIL-2018-v2",
countries = c("ES"), max_n = 50)
bench <- benchmark_lucas_2018(
pedons,
esdb_root = "soil_data/eu_lucas/ESDB-Raster-Library-1k-GeoTIFF-20240507",
fill_texture_from = "soilgrids")
bench$accuracy
bench$per_rsg
} # }