% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spectra-ingest.R
\name{pedons_from_spectral_table}
\alias{pedons_from_spectral_table}
\title{Build PedonRecords with attached Vis-NIR/MIR spectra from a table}
\usage{
pedons_from_spectral_table(
  reflectance,
  metadata,
  id_col = "id",
  profile_col = NULL,
  wavelengths = NULL,
  resample_to = NULL,
  property_map = NULL,
  label_map = NULL,
  normalize = c("auto", "none", "percent"),
  keep_properties = FALSE,
  verbose = TRUE
)
}
\arguments{
\item{reflectance}{Reflectance data: a matrix / data.frame with rows =
samples and columns named by wavelength (nm); OR a long data.frame with
\code{id_col}, \code{wavelength_nm}, \code{reflectance}; OR a path to a
CSV in either form.}

\item{metadata}{A data.frame with one row per sample carrying \code{id_col}
plus lab attributes and optional taxonomic labels and \code{lat}/
\code{lon}. Rows are aligned to \code{reflectance} by \code{id_col}.}

\item{id_col}{Sample identifier column shared by both tables (default
\code{"id"}).}

\item{profile_col}{Column grouping samples into profiles (default
\code{id_col}: one profile per sample, e.g. a topsoil library).}

\item{wavelengths}{Optional explicit wavelength vector (nm) when the
reflectance columns are not wavelength-named.}

\item{resample_to}{Optional target wavelength grid (nm) to linearly resample
every spectrum onto (e.g. \code{350:2500}); default keeps the native grid.}

\item{property_map, label_map}{Optional named lists overriding the alias
auto-detection, e.g. \code{property_map = list(clay_pct = "ARGILA")}.}

\item{normalize}{One of \code{"auto"} (divide by 100 when values look like
percent), \code{"percent"}, or \code{"none"}.}

\item{keep_properties}{If \code{TRUE}, also write the mapped lab attributes to
the horizons (default \code{FALSE} -- a field pedon usually has only the
scan, which is the scenario the spectral fill targets).}

\item{verbose}{Print a one-line summary (default \code{TRUE}).}
}
\value{
A list of \code{\link{PedonRecord}} objects.
}
\description{
Groups a reflectance + metadata table by profile and returns one
\code{\link{PedonRecord}} per profile, with each profile's sample rows stacked
into \code{$spectra$vnir} (rows = horizons, cols = wavelengths) and the lab
attributes / depths written to the horizons. Taxonomic labels are stored in
\code{$site} (\code{reference_wrb} / \code{reference_sibcs} /
\code{reference_st}). These pedons are the query objects for
\code{classify_*(gapfill = list(method = "spectra", ossl_library = <lib>))}.
}
\seealso{
\code{\link{read_spectral_library}}, \code{\link{benchmark_spectral_fill}}
}
