% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spatial-prior.R
\name{spatial_prior}
\alias{spatial_prior}
\title{Spatial prior over RSGs (or Orders) at a pedon's location}
\usage{
spatial_prior(
  pedon,
  source = c("soilgrids", "embrapa"),
  system = c("wrb2022", "usda"),
  ...
)
}
\arguments{
\item{pedon}{A \code{\link{PedonRecord}} with non-NULL
\code{site$lat} / \code{site$lon}.}

\item{source}{Backend to query: \code{"soilgrids"} (default) or
\code{"embrapa"}.}

\item{system}{Classification system: \code{"wrb2022"} (default) or
\code{"usda"}. Embrapa source forces \code{"sibcs5"}
internally regardless of this argument.}

\item{...}{Passed through to the backend
(\code{\link{spatial_prior_soilgrids}} or
\code{\link{spatial_prior_embrapa}}).}
}
\value{
A \code{data.table} with columns \code{rsg_code} (character)
        and \code{probability} (numeric, summing to 1). Empty if the
        buffer extracts no valid pixels -- callers should check
        \code{nrow()}.
}
\description{
Top-level dispatcher. Reads a categorical raster of soil classes
(SoilGrids globally, Embrapa for Brazil), buffers the pedon's
coordinates, tallies pixel classes within the buffer, and returns
the empirical class frequency as a probability distribution.
}
\details{
The prior is intentionally separate from the deterministic key.
Pass the returned data.table to \code{\link{classify_wrb2022}} via
the \code{prior} argument; the result will then carry a
\code{prior_check} entry (consistent / inconsistent / not_run).
}
