Soil morphology, observed properties, and geomorphic context represent a complex package of interrelated information that can be difficult to analyze and communicate as a whole. Graphical methods such as soil profile sketches and cross-sections represent a few of the possible methods commonly used to report on these kind of data. The Algorithms for Quantitative Pedology (AQP) project encompasses several related R packages tailored to this style of work. A specialized data structure (SoilProfileCollection) maintains linkages between soil horizons, diagnostic features, above-ground data, and geomorphic context. SoilProfileCollection objects can be filtered, subset, resampled (over new depth intervals), and re-ordered; all while preserving links to above and below-ground, linked data. Functions are provided for the conversion of soil colors to and from Munsell notation and several other color space coordinates. Graphical methods for the SoilProfileCollection provide a simple but flexible framework for the design and layout of soil profile sketches, aligned to x and or y axes defined by linked data.

Function Index by Topic

SoilProfileCollection Objects


  • depths(): init an SPC from data.frame
  • site(): set or add site-level attributes of an SPC
  • quickSPC(): quickly build an SPC from simple text templates
  • random_profile(): generate random SPC from suite of depth functions




  • glom(): extract horizons based on overlap criteria defined by point or interval
  • trunc(): truncate SPC to given depth interval
  • subset(): subset profiles based on logical expressions
  • subsetHz(): subset horizons based on logical expressions
  • [: data.frame-like subsetting of profiles (i-index) and/or horizons (j-index)
  • [[: access site or horizon-level columns by name
  • k-index expressions: .FIRST, .LAST, .HZID, .NHZ



  • combine(), c(): combine multiple SPCs into a single SPC
  • duplicate(): duplicate profiles within a SPC
  • perturb(): randomly adjust horizon thickness or depths to simulate from a template SPC
  • warpHorizons(): expand / contract horizon thickness
  • harmonize(): create new profiles within a SPC based sets of related horizon-level data
  • hzAbove(), hzBelow(): locate horizons above or below some criteria
  • unique(): determine uniqueness among profiles of an SPC via MD5 hash
  • split(): split SPC into list of SPCs based on grouping factor
  • site(): get site data as data.frame
  • horizons(): get horizon data as data.frame
  • replaceHorizons(): replace horizon data
  • diagnostic_hz(): get/set diagnostic features
  • restrictions(): get/set restrictions
  • denormalize(): convert site-level data into horizon-level data via replication
  • compositeSPC(): downgrade an SPC to list of site and horizon-level data


  • profileApply(): apply a function to each profile within an SPC (slow but simple interface)
  • summarizeSPC(): perform group-wise summaries over profiles within an SPC
  • transform(): modify a SPC using expressions that operation on site or horizon-level data

Change of Support

  • dice(): convert SPC to 1 depth-unit intervals by replication
  • slab(): apply an aggregate function over groups within a “dice()-ed” SPC
  • spc2mpspline(): interface to equal-area spline fitting from mpspline2 package
  • segment(): generate segment labels for depth-weighted aggregation
  • L1_profiles(): create representative profiles via multivariate median (L1 estimator)
  • slicedHSD(): apply Tukey’s HSD over groups within a “dice()-ed” SPC

Horizon Depth Logic

Data QC

Object Coercion

  • as(SPC, 'list'): convert SPC to list
  • as(SPC, 'data.frame'): convert site and horizon data to data.frame
  • as(SPC, 'sf'): convert site and spatial data to sf object

Spatial Data

  • prj(): get/set coordinate reference system (CRS) metadata
  • initSpatial(): set (site-level) column names containing coordinates
  • getSpatial(): get spatial data (site + coordinates) from an SPC

Internal Consistency

  • checkSPC(): check SPC for internal consistency
  • rebuildSPC(): re-make an SPC from a previous version of aqp (rarely required)

Soil Profile Sketches

Soil Color / Color Science

Color Conversion

  • col2Munsell(): convert various color notations to Munsell notation
  • munsell2rgb(): convert Munsell notation to sRGB or CIELAB color coordinates
  • parseMunsell(): parse and optionally convert a munsell color
  • spec2Munsell(): estimate the closest Munsell color given reflectance spectra in the visible range
  • getClosestMunsellChip(): estimate a reasonably close Munsell color given non-standard notation
  • estimateSoilColor(): estimate moist soil color from dry soil color (and vice versa)



  • colorChart(): Munsell color book representation of color frequency
  • aggregateColor(): estimate color proportions within an SPC according within groups of horizons
  • colorQuantiles(): marginal and L1 quantiles of color in CIELAB coordinates


  • huePosition(): generate an ordered factor of the standard Munsell hues
  • huePositionCircle(): graphical representation of the standard Munsell hues, with optional simulation of common color vision deficiency
  • simulateColor(): simulate a range of Munsell colors given measures of central tendency and spread
  • previewColors(): graphical preview of colors as a grid or via nMDS
  • soilPalette(): generate swatch-like arrangements of colors and labels
  • equivalentMunsellChips(): for a specified Munsell color, identify other Munsell colors with a very lower CIE2000 color contrast difference

Simulation of Mixtures

  • mixMunsell(): simulate an subtractive mixture of pigments specified in Munsell notation
  • plotColorMixture(): simulate a subtractive mixture of pigments, display reflectance spectra

Numerical Classification of Soil Profiles

  • NCSP(): numerical classification of soil profiles, within a SoilProfileCollection
  • compareSites(): pair-wise comparison of site-level data from a SoilProfileCollection


Soil Texture

Coarse Fragments

Soil Taxonomy

Generalized Horizon Labels (GHL)

  • generalize.hz(): apply REGEX rules to group horizon designations into a reduced set of “generalized horizon labels”
  • evalGenHZ(): evaluate internal consistency of assigned GHL
  • genhzTableToAdjMat(): convert a cross-tabulation of GHL vs. original horizon designations to adjacency matrix
  • extract most likely horizon boundary depths from probability depth functions
  • guessGenHzLevels(): estimate the correct ordering of GHL given horizon depths
  • GHL(): get/set GHL metadata for a SoilProfileCollection


Accuracy and Uncertainty

Overlapping Annotation

  • findOverlap(): identify overlap within a vector of positions based on a given threshold
  • overlapMetrics(): metrics of overlap within a vector or positions based on a given threshold
  • fixOverlap(): attempt the minimum of adjustments to vector of positions such that a given distance threshold is enforced

Example Data

  • sp1
  • sp2
  • sp3
  • sp4
  • sp5
  • sp6
  • sierraTransect
  • wilson2022
  • rowley2019
  • jacobs2000
  • osd
  • SPC.with.overlap
  • us.state.soils
  • soil_minerals
  • munsell
  • equivalent_munsell
  • munsellHuePosition
  • munsell.spectra
  • spectral.reference
  • ROSETTA.centroids
  • reactionclass
  • soiltexture