% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/soilgrids-depth-fill.R
\name{apply_soilgrids_depth_prior}
\alias{apply_soilgrids_depth_prior}
\title{Fill missing horizon attributes from a SoilGrids depth prior}
\usage{
apply_soilgrids_depth_prior(
  pedon,
  attrs = NULL,
  depth_profiles = NULL,
  overwrite = FALSE
)
}
\arguments{
\item{pedon}{A \code{\link{PedonRecord}} with at least one horizon.
For the live fetch it must also carry \code{site$lat} and
\code{site$lon}.}

\item{attrs}{Character vector of horizon columns to fill. Defaults to
all SoilGrids-backed attributes: \code{clay_pct}, \code{sand_pct},
\code{silt_pct}, \code{ph_h2o}, \code{oc_pct}, \code{cec_cmol}.}

\item{depth_profiles}{Optional named list mapping an attribute to a
numeric vector of six slice values (0-5 ... 100-200 cm). When
supplied the SoilGrids network call is skipped entirely -- this
is the path the test suite and offline users take.}

\item{overwrite}{If \code{FALSE} (default) only \code{NA} cells are
filled. If \code{TRUE}, every requested cell is overwritten
(subject to the provenance authority order).}
}
\value{
Invisibly, the mutated \code{pedon}. An attribute
        \code{"soilgrids_depth_fill"} on the return value records how
        many cells were filled.
}
\description{
For each horizon and each requested attribute, interpolates the value
at the horizon's mid-depth from the six standard SoilGrids 2.0 depth
slices (0-5, 5-15, 15-30, 30-60, 60-100, 100-200 cm) and writes it
into the pedon with \code{source = "inferred_prior"}. Existing values
are preserved unless \code{overwrite = TRUE}; the
\code{\link{PedonRecord}} authority order means a SoilGrids prior can
never silently displace a measured, spectra-predicted or VLM-extracted
value.
}
\details{
This is the depth-resolved companion to
\code{\link{spatial_prior_soilgrids}} (which returns a site-level RSG
probability vector, not horizon attributes), and the attribute-fill
stage of \code{\link{classify_from_photos}}.
}
\examples{
\dontrun{
p <- make_cambisol_canonical()
p$horizons$clay_pct <- NA_real_
# Offline: supply the six-slice profiles directly.
apply_soilgrids_depth_prior(
  p, attrs = "clay_pct",
  depth_profiles = list(clay_pct = c(18, 20, 24, 28, 30, 30)))
}
}
