% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spectra-train.R
\name{predict_from_spectra}
\alias{predict_from_spectra}
\title{Predict soil properties from spectra}
\usage{
predict_from_spectra(
  pedon_or_spectra,
  models = NULL,
  properties = NULL,
  overwrite = FALSE,
  verbose = TRUE,
  ...
)
}
\arguments{
\item{pedon_or_spectra}{A \code{\link{PedonRecord}} (predictions
merged into the pedon) OR a numeric matrix / vector of raw
Vis-NIR spectra (rows = horizons, columns = wavelengths).}

\item{models}{A named list of \code{soilKey_pls_model} objects
(output of \code{\link{train_pls_from_ossl}}). Required.}

\item{properties}{Character vector of property names to predict.
Defaults to all properties in \code{models}.}

\item{overwrite}{Passed to \code{\link{fill_from_spectra}} when
\code{pedon_or_spectra} is a PedonRecord.}

\item{verbose}{Verbosity passed downstream.}

\item{...}{Ignored (reserved for future backends).}
}
\value{
Either the mutated \code{PedonRecord} (invisibly) or a
        data.table with columns \code{horizon_idx}, \code{property},
        \code{value}, \code{pi95_low}, \code{pi95_high},
        \code{n_neighbors}.
}
\description{
Ergonomic, named entry point for the OSSL-backed predictive
pipeline. Accepts either a \code{\link{PedonRecord}} or a numeric
spectra matrix, applies the same preprocessing used at training
time (recorded on each model), and returns predictions in the
canonical long-form schema.
}
\details{
When \code{pedon_or_spectra} is a \code{PedonRecord}, this
function delegates to \code{\link{fill_from_spectra}} with
\code{method = "pretrained"} and the predictions are written back
to the pedon (with \code{source = "predicted_spectra"} provenance).
When \code{pedon_or_spectra} is a numeric matrix or vector, this
function returns the prediction data.table directly without
touching any pedon.
}
\examples{
\donttest{
if (requireNamespace("pls", quietly = TRUE)) {
  data(ossl_demo_sa)
  models <- try(train_pls_from_ossl(ossl_demo_sa,
                                      properties = c("clay_pct", "ph_h2o"),
                                      min_n = 10L,
                                      validation = "none"),
                 silent = TRUE)
  # Prediction step needs a synthetic pedon with spectra attached.
  # predict_from_spectra(my_pedon, models = models)
}
}
}
