Skip to contents

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.

Usage

spatial_prior(
  pedon,
  source = c("soilgrids", "embrapa"),
  system = c("wrb2022", "usda"),
  ...
)

Arguments

pedon

A PedonRecord with non-NULL site$lat / site$lon.

source

Backend to query: "soilgrids" (default) or "embrapa".

system

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

...

Passed through to the backend (spatial_prior_soilgrids or spatial_prior_embrapa).

Value

A data.table with columns rsg_code (character) and probability (numeric, summing to 1). Empty if the buffer extracts no valid pixels – callers should check nrow().

Details

The prior is intentionally separate from the deterministic key. Pass the returned data.table to classify_wrb2022 via the prior argument; the result will then carry a prior_check entry (consistent / inconsistent / not_run).