# sample data
data(sp1)
# add color vector
sp1$soil_color <- with(sp1, munsell2rgb(hue, value, chroma))
# promote to SoilProfileCollection
depths(sp1) <- id ~ top + bottom
# plot profiles
plot(sp1)
# extract top/bottom depths associated with all A horizons
f <- function(i) {
h <- horizons(i)
idx <- grep('^A', h$name)
c(min(h$top[idx]), max(h$bottom[idx], na.rm=TRUE))
}
# apply function to sp1, result is a list
a <- profileApply(sp1, f, simplify=FALSE)
# convert list into matrix
a <- do.call('rbind', a)
# plot
plot(sp1)
# annotate with brackets
# note that plotting order is derived from the call to `plot(sp1)`
addBracket(a[, 1], a[, 2], col='red')
# more interesting example using diagnostic horizons
if(require(soilDB)) {
# load some sample data with diagnostic horizons
data(loafercreek)
# extract first 15 profiles
x <- loafercreek[1:15, ]
s <- site(x)
# plot
par(mar=c(0,0,0,0))
plot(x, name='hzname', id.style='top')
# add brackets describing the argillic horizon
addDiagnosticBracket(x, 'argillic horizon', col='red')
# add brackets describing paralithic contact
addDiagnosticBracket(x, 'paralithic contact', col='blue')
}
Run the code above in your browser using DataLab