% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spectra-ossl.R
\name{fill_from_spectra}
\alias{fill_from_spectra}
\title{Fill missing soil attributes from spectra via OSSL}
\usage{
fill_from_spectra(
  pedon,
  library = "ossl",
  region = c("global", "south_america", "north_america", "europe", "africa"),
  properties = c("clay_pct", "sand_pct", "silt_pct", "cec_cmol", "bs_pct", "ph_h2o",
    "oc_pct", "fe_dcb_pct", "caco3_pct"),
  method = c("mbl", "plsr_local", "pretrained"),
  preprocess = "snv+sg1",
  k_neighbors = 100L,
  overwrite = FALSE,
  ossl_library = NULL,
  ossl_models = NULL,
  verbose = TRUE
)
}
\arguments{
\item{pedon}{A \code{\link{PedonRecord}} with a
\code{spectra$vnir} matrix.}

\item{library}{Currently only \code{"ossl"} is supported.}

\item{region}{One of \code{"global"}, \code{"south_america"},
\code{"north_america"}, \code{"europe"}, \code{"africa"}.
Used to subset the OSSL training data when supported by the
underlying backend.}

\item{properties}{Character vector of OSSL-supported property names
to predict. Default covers the most-requested
WRB/SiBCS-relevant attributes.}

\item{method}{One of \code{"mbl"}, \code{"plsr_local"},
\code{"pretrained"}.}

\item{preprocess}{Pre-processing pipeline; passed to
\code{\link{preprocess_spectra}}.}

\item{k_neighbors}{Number of neighbours for memory-based methods.}

\item{overwrite}{If \code{FALSE} (default), only fill cells whose
existing provenance is weaker than \code{predicted_spectra}.}

\item{ossl_library}{Optional OSSL library object (see
\code{\link{predict_ossl_mbl}}).}

\item{ossl_models}{Optional named list of pretrained models (see
\code{\link{predict_ossl_pretrained}}).}

\item{verbose}{If \code{TRUE}, prints a cli summary.}
}
\value{
The mutated pedon, invisibly. Provenance entries with
        \code{source = "predicted_spectra"} are added per
        (horizon, property).
}
\description{
Given a \code{\link{PedonRecord}} carrying a \code{spectra$vnir}
matrix (rows = horizons, columns = wavelengths in nm), pre-processes
the spectra, predicts the requested soil properties using the chosen
OSSL-backed method, and writes the predictions into the pedon's
horizons table via \code{pedon$add_measurement(..., source =
"predicted_spectra")}. Each call updates the pedon's provenance log
so that downstream classification can derive an evidence grade.
}
\details{
By default, predicted values do \strong{not} overwrite measured
values (the \code{add_measurement()} authority logic protects them).
Setting \code{overwrite = TRUE} forces overwrite of any non-measured
value.
}
\seealso{
\code{\link{preprocess_spectra}}, \code{\link{predict_ossl_mbl}},
         \code{\link{predict_ossl_plsr_local}},
         \code{\link{predict_ossl_pretrained}},
         \code{\link{pi_to_confidence}}.
}
