Introduction

Plotting several SoilProfileCollection objects in the same context can be challenging. This document illustrates two methods for organizing profiles into groups within a single sketch.

Get Data

We are going to demonstrate some concepts using both KSSL (lab) and OSD (typical morphology) data for the Sobrante and Auburn soil series.

library(aqp)
library(soilDB)
library(scales)
library(RColorBrewer)

# get OSD data for select series
osd <- fetchOSD(c('sobrante', 'auburn'))

# get KSSL data for these series
kssl.1 <- fetchKSSL('sobrante')
kssl.2 <- fetchKSSL('auburn')

Note that the KSSL-derived SPC objects share the same structure, but the OSD-derived object does not. This will have implications on how the data can be displayed within the same sketch.

str(kss1.1)
str(kss1.2)
str(osd)

Method 1: Split Sketch into Groups

We can easily combine the two KSSL-derived objects using combine(). The colors and legend can be automatically generated from the entire set of (combined) clay values.

# combine similar SPCs into a new SPC
g <- combine(kssl.1, kssl.2)

# there is some variabilty in capitalization: need to normalize these names
table(g$taxonname)
## 
##   Auburn   AUBURN Sobrante SOBRANTE 
##       12        2        2        4
# normalize taxonname (soil series) via capitalization
g$taxonname <- toupper(g$taxonname)

# plot groups of profiles organized by normalized taxonname
par(mar=c(1,1,4,3))
groupedProfilePlot(g, groups = 'taxonname', name='hzn_desgn', color='clay', label='pedon_id', id.style='side')

Method 2: Plot SPC Objects of Variable Provenance

SoilProfileCollection objects from any source can be included into the same sketch using plotMultipleSPC().

Plot

# assemble list of SPCs
spc.list <- list(
  osd, 
  kssl.1, 
  kssl.2
)

# assemble list of arguments to plotSPC for each object
# note the use of .color for pre-computed value->color 
args.list <- list(
  list(name = 'hzname', color = 'soil_color', id.style = 'side'), 
  list(name = 'hzn_desgn', label = 'pedon_id', id.style = 'side'), 
  list(name = 'hzn_desgn', label = 'pedon_id', id.style = 'side')
  )

par(mar=c(1,1,3,3))
plotMultipleSPC(
  spc.list, 
  group.labels = c('OSD', 'Sobrante', 'Auburn'), 
  args = args.list, 
  merged.legend = 'clay', merged.legend.title = 'Clay Content (%)',
  max.depth = 140, label.offset = 5
)


This document is based on aqp version 1.29 and soilDB version 2.5.9.