% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spectra-ingest.R
\name{read_spectral_library}
\alias{read_spectral_library}
\title{Read a Vis-NIR / MIR reflectance + lab table into an OSSL-shaped library}
\usage{
read_spectral_library(
  reflectance,
  metadata,
  id_col = "id",
  wavelengths = NULL,
  resample_to = NULL,
  property_map = NULL,
  label_map = NULL,
  normalize = c("auto", "none", "percent"),
  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{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{verbose}{Print a one-line summary (default \code{TRUE}).}
}
\value{
A list with \code{Xr} (numeric reflectance matrix), \code{Yr} (data
        frame of mapped properties + labels + \code{lat}/\code{lon}), and
        \code{metadata} (provenance). Ready to pass as \code{ossl_library=}.
}
\description{
Turns an arbitrary spectral dataset (e.g. a Brazilian Vis-NIR/MIR library)
into the canonical \code{list(Xr, Yr, metadata)} object consumed by
\code{\link{fill_from_spectra}} and
\code{\link{classify_by_spectral_neighbours}}. Column names are mapped to the
package's canonical attributes (clay_pct, sand_pct, ..., and the taxonomic
label columns \code{wrb_rsg} / \code{sibcs_ordem} / \code{usda_order}) via a
built-in alias table (including Portuguese headers such as
\emph{argila} / \emph{silte} / \emph{carbono}) or an explicit
\code{property_map} / \code{label_map}.
}
\seealso{
\code{\link{pedons_from_spectral_table}},
  \code{\link{benchmark_spectral_fill}}, \code{\link{fill_from_spectra}}
}
