/dsm-soil:soil-sampling-designfrom dsm-soil
Helps design soil sampling schemes for digital soil mapping — choose method (cLHS, maxvol, scLHS, etc.), size, and placement for new or legacy data. Includes an R toolkit (soilsampling package) for generating sampling points.
Ships in dsm-soil. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Forged from the DSM knowledge wiki. The wiki is the source of truth. Key pages: sampling-design, soilsampling, mlsampling, sample-representativeness, spatiotemporal-sampling, landscape-heterogeneity, scale-dependence, area-of-applicability, spatial-cross-validation. Sampling is the first step of digital-soil-mapping-workflow; hand map-accuracy validation to soil-map-validation.
Sampling is upstream of every accuracy claim — and there is no one-size design. Choose by what you are optimizing and what constrains you, not by habit. The axes:
| Your objective / constraint | Reach for | Source |
|---|---|---|
| Efficient covariate-space coverage, few points | cLHS (condition on covariates only) | Minasny & McBratney |
| Feature space, deterministic / D-optimal (span the extremes) | maxvol (ss_maxvol) | Petrovskaia 2021 |
| cLHS + spatial uniformity | scLHS | Gao 2016 |
| Add a time axis (or autocorrelation-aware) | acLHS / space-time | Le & Vargas; Brus |
| Beat cLHS on accuracy (fuzzy-cluster) | IHS | Yang 2016 |
| Several target properties at once | MPRS / Wang dual-space | Zhang 2022; Wang 2026 |
| Density should track variability | heterogeneity-adaptive (CV-of-DEM → subregions) | Wang 2026 |
| Expensive access; sample a small representative area | Reference Area (autoRA / Gower) | Rodrigues 2025 |
| Scale an existing sampling style cheaply from terrain | DL segmentation (DualTrans) | Pham 2025 |
| Certify map accuracy (MRV) | probability sampling (design-based) | Wadoux; de Gruijter |
| Tight logistics/budget | cost- / accessibility-constrained cLHS | Godinho Silva; Sena |
| You already have legacy points | assess representativeness → supplement | An; Zhang & Zhu; Liu |
soilsampling R packageMost of the catalog is runnable in one sf-native package (soilsampling, GPL-3; pak::pak("ccarbajal16/soilsampling")). Depends on sf, terra, clhs, randomForest. Map the design to the function:
| Design | Function |
|---|---|
| Probability sample (→ design-based validation) | ss_random(), ss_stratified() |
| Spatial coverage (MSSD k-means strata) | ss_coverage(), ss_coverage_equal_area() |
| Feature space, D-optimal / maxvol | ss_maxvol(feature_sf, n, features, normalize, add_coords, min_dist) |
| Feature space, cLHS | ss_clhs_sample() |
| Objective sample size (KL divergence) | ss_kl_size() |
| Refine locations (RF + simulated annealing, min CV-MSE) | ss_rf_optimize() |
| Inaccessible sites → reachable substitutes (Gower buffer) | ss_alt_sites() |
| Composite sampling | ss_composite() |
| Check the design | ss_coverage_efficiency() (CV/Gini/min-max), ss_distance_summary() |
Typical flow: derive covariates (terra::terrain on a DEM + spectral indices) → assemble a candidate sf of pixels → pick a design function → validate with ss_coverage_efficiency() → export with ss_to_sf() / ss_to_data_frame(). ss_maxvol() is deterministic (reproducible surveys) and can be constrained to a land-cover class (filter the candidate sf first) or spaced with min_dist.
Supplementing an existing design → MLSampling (devtools::install_github("ccarbajal16/MLSampling")). Where soilsampling designs from scratch, MLSampling adds points given existing samples + covariates, targeting hotspots: create_ml_sampling_tool() then run_bdl() (Bayesian DL — highest epistemic-uncertainty cells), run_rf_optimization() (FSCS: coverage in the space of the most important RF covariates, Wadoux 2019), run_udl()/run_ufn() (the Pham DL architectures), or run_ensemble() (BDL+RF voting). Active-learning companion to LPD-guided resampling. Caveat: DL selectors imitate their objective — confirm the added points raise held-out accuracy. Fertility-index sibling (other skill): soilquality (SQI → fertility).
ss_kl_size()); an RF + simulated-annealing loop then refines where the points go by
minimizing cross-validated RF MSE (ss_rf_optimize()) — sizing and siting as algorithms, not guesses.run_bdl/run_rf_optimization → new points at uncertainty/feature-space hotspots).Don't sample uniformly. Compute local heterogeneity (landscape-heterogeneity: SDI, Moran's I, distribution shape; or CV-of-DEM in a window) and put more samples where the landscape varies more, fewer where it's uniform. A pre-modelling triage also sets honest accuracy expectations per area.
Record date/season on every point (many legacy points lack it). Design where and when to sample (spatiotemporal-sampling: Brus space-time — design/model/hybrid), integrating static + dynamic covariates and matching the process timescale (seasonal vs decadal).
Cost-constrained cLHS trades a little accuracy for big savings; accessibility-aware designs substitute reachable
alternatives for inaccessible points. Essential where terrain/logistics dominate (Andes, Amazon). The Reference
Area design is itself a major cost lever. Concrete recipe for an unreachable site: score environmental
similarity in a buffer (Gower's index; or Mahalanobis, Malone 2019), drop too-close candidates, and rank the
reachable substitute that best preserves the covariate signature — ss_alt_sites() (or clhs::similarity_buffer).
Distilled from: Minasny & McBratney (cLHS), Bouasria 2023 (learning-curve sizing, cLHS-vs-SRS variance,
landscape-heterogeneity triage), Carbajal 2025 (cLHS in the Andes; small-n regime), Wadoux (probability/design-based),
Hengl & Abbruzzini (legacy per-property n, spatial de-clustering), Yang & Li 2026 (the design catalog: scLHS, acLHS,
IHS, MPRS, supplemental, representativeness assessment, space-time), Pham 2025 (DL segmentation site selection),
Rodrigues 2025 (Reference Area / autoRA-Gower), and Wang 2026 (heterogeneity-adaptive, dual-space, multi-property).
Runnable toolkit: the soilsampling R package (Carbajal) — stratification, coverage,
maxvol/D-optimal (Petrovskaia 2021), cLHS, KL-sizing, RF-refinement, accessibility alternatives, diagnostics —
and MLSampling (Carbajal) for ML/DL uncertainty-guided supplemental sampling
(BDL/FSCS/UDL/UFN/ensemble; implements Pham 2024 + Wadoux 2019).
Full citations in the wiki sources/.
Portable build from the DSM knowledge wiki (the source of truth). Obsidian cross-references were flattened for standalone use; regenerate with build.ps1.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ccarbajal16/soil-dsm-skills --plugin dsm-soil12 skills in this plugin
/digital-soil-mapping-workflowRun a digital soil mapping (DSM) project end to end — from framing the target and assembling scorpan covariates, through sampling design, model selection, handling spatial autocorrelation, training, and producing a map with calibrated uncertainty. Use when planning or reviewing any project that predicts a soil property (SOC, texture, pH, …) across space (and optionally time) from environmental covariates. Triggers: "digital soil mapping", "DSM", "predict soil property from covariates", "soil map", "scorpan", "which model for soil mapping", "covariates for soil", "map SOC / soil carbon"./ensemble-ml-for-soilDecide whether to combine machine-learning models at all, and if so how — by measuring the gain available before building any combiner. Covers the ambiguity/diversity ceiling, the weighting spectrum (simple average, R²-weighted, Bates–Granger, AIC/BIC, NNLS/SuperLearner, Granger–Ramanathan, learned meta-models, attention, per-pixel selection), out-of-fold stacking under spatial CV, cross-fitting the combiner, voting for classification, and significance testing of the margin. Use when someone proposes an ensemble, reports an ensemble gain, or asks whether their averaging scheme is "too simple". Triggers: "ensemble machine learning", "model stacking", "stacked generalisation", "SuperLearner", "meta-learner", "meta-model", "weighted average ensemble", "R2-weighted ensemble", "simple average ensemble", "Bates-Granger", "Granger-Ramanathan", "NNLS weights", "non-negative least squares", "caretStack", "mlr3pipelines stacking", "voting ensemble", "hard voting", "soft voting", "blending", "bagging vs boosting vs stacking", "ensemble gain", "does stacking help", "combine RF and XGBoost", "which model to combine", "base learner diversity", "error correlation", "out-of-fold predictions", "level-one dataset", "landmap", "MACHISPLIN", "spatial ensemble", "per-pixel model selection", "combine my model with SoilGrids"./hybrid-process-ml-socDesign and build hybrid soil-organic-carbon models that fuse a process-oriented model (RothC / CENTURY / Millennial) with machine learning (Random Forest / QRF) to predict SOC stock in space AND time — getting ML's spatial accuracy together with the process model's physically-plausible temporal dynamics. Use when a task needs SOC *change* over time (not just a static map), when pure ML gives implausible temporal trends, or when integrating mechanistic knowledge into data-driven soil mapping. Triggers: "hybrid soil carbon model", "process + machine learning", "POML", "space-time SOC", "RothC + random forest", "physically plausible SOC prediction", "knowledge-guided ML for soil"./ml-for-soil-predictionChoose, tune, and reason about machine-learning models for predicting soil properties (SOC, texture, pH, …) — Random Forest, Quantile Regression Forests, gradient boosting, and deep learning — including per-pixel uncertainty and interpretability. Use when the task is the ML modelling craft itself: which algorithm, how to tune it, how to get honest uncertainty, whether deep learning is worth it, why an ML model underperforms. Triggers: "random forest for soil", "QRF", "which ML model", "deep learning soil", "CNN / ANN soil carbon", "hyperparameters", "feature importance / SHAP", "prediction interval", "ML model gives bad R²"./rothc-temporal-modellingSet up, initialize, calibrate, validate, and interpret the RothC (Rothamsted Carbon) model — and CENTURY-family process models — for simulating soil organic carbon stock and its change over time. Use when modelling SOC dynamics under management or climate scenarios, initializing RothC pools (spin-up), calibrating decay constants, choosing carbon inputs, adapting RothC to a region/practice, or judging whether a RothC result is trustworthy. Triggers: "RothC", "CENTURY / CenW", "soil carbon model", "carbon pools DPM/RPM/BIO/HUM/IOM", "spin-up / initialize SOC pools", "calibrate RothC", "SOC under climate change", "carbon input estimation", "first-order decay"./soc-stock-mrvQuantify, report, and verify soil-organic-carbon stock and its change over time for carbon markets / MRV (Monitoring, Reporting, Verification) — computing SOC stock, estimating change and its uncertainty at the field/project support, and applying the uncertainty deduction that determines creditable tons. Use when a task involves soil carbon crediting, an MRV framework (VM0042, VT0014), SOC stock-change detectability, or reporting SOC with defensible uncertainty. Triggers: "SOC MRV", "soil carbon credits", "carbon farming verification", "SOC stock change", "uncertainty deduction", "how much SOC can we credit", "monitoring reporting verification soil carbon".Other plugins' skills for the same job