All of these functions will be simplified / documented in the near future, stay tuned.
Pending.
Source colors are in sRGB (D65) colorspace, as converted from Munsell
notation using aqp::munsell2rgb()
.
Trivial example using some of the aqp
built-in data.
library(aqp)
library(farver)
library(cluster)
library(ape)
library(colorspace)
library(soilDB)
library(sharpshootR)
# example data
data(sp5)
# semi-random subset
set.seed(10101)
idx <- sample(length(sp5), size = 15, replace = FALSE)
# truncate to 150cm for simplicity
x <- trunc(sp5[idx, ], 0, 150)
# quick check
par(mar = c(0, 0, 0, 1))
plotSPC(x, width = 0.35)
# convert HEX color notation -> sRGB [0,1]
rgb.data <- t(col2rgb(x$soil_color)) / 255
# copy to horizon level attributes of SPC
x$r <- rgb.data[, 1]
x$g <- rgb.data[, 2]
x$b <- rgb.data[, 3]
# develop color signature
pig <- soilColorSignature(x, method = 'depthSlices', RescaleLightnessBy = 5)
knitr::kable(pig, digits = 3, row.names = FALSE)
soil | A.0.1 | A.0.5 | A.0.9 | B.0.1 | B.0.5 | B.0.9 | L.0.1 | L.0.5 | L.0.9 |
---|---|---|---|---|---|---|---|---|---|
soil100 | 5.447 | 8.769 | 9.510 | 15.982 | 22.157 | 21.267 | 6.177 | 10.191 | 12.184 |
soil102 | 7.275 | 13.824 | 11.642 | 8.138 | 16.434 | 20.356 | 6.235 | 10.186 | 8.212 |
soil107 | 4.794 | 7.275 | 7.049 | 9.798 | 8.138 | 21.026 | 6.296 | 6.235 | 6.274 |
soil155 | 7.275 | 7.275 | 7.275 | 8.138 | 8.138 | 8.138 | 6.235 | 6.235 | 6.235 |
soil156 | 2.037 | 2.037 | 13.220 | 5.446 | 5.446 | 19.206 | 6.148 | 6.148 | 10.165 |
soil167 | 4.794 | 4.794 | 15.597 | 9.798 | 9.798 | 17.731 | 6.296 | 6.296 | 8.250 |
soil168 | 7.275 | 7.275 | 9.453 | 8.138 | 8.138 | 5.188 | 6.235 | 6.235 | 16.139 |
soil189 | 7.275 | 12.172 | 16.673 | 8.138 | 19.396 | 31.254 | 6.235 | 12.308 | 10.235 |
soil226 | 2.037 | 2.037 | 2.037 | 5.446 | 5.446 | 5.446 | 6.148 | 6.148 | 6.148 |
soil332 | 8.630 | 7.275 | 1.346 | 8.687 | 8.138 | 6.864 | 6.306 | 6.235 | 8.321 |
soil340 | 7.275 | 11.642 | 13.220 | 8.138 | 20.356 | 19.206 | 6.235 | 8.212 | 10.165 |
soil341 | 7.275 | 8.826 | 8.558 | 8.138 | 14.803 | 13.285 | 6.235 | 8.294 | 6.323 |
soil40 | 2.037 | 4.794 | 5.447 | 5.446 | 9.798 | 15.982 | 6.148 | 6.296 | 6.177 |
soil419 | 7.275 | 19.442 | 5.293 | 8.138 | 26.882 | 24.202 | 6.235 | 8.259 | 16.177 |
soil79 | 7.275 | 6.103 | 8.096 | 8.138 | 7.305 | 8.186 | 6.235 | 4.293 | 8.229 |
Plot results as dendrogram.
# copy ID to rownames
row.names(pig) <- pig[, 1]
# euclidean distance, leaving out the ID
d <- daisy(pig[, -1], stand = FALSE, metric = 'euclidean')
dd <- diana(d)
plotProfileDendrogram(x, clust = dd, scaling.factor = 0.33, y.offset = 4, width = 0.35)
s.list <- c('amador', 'redding', 'pentz', 'willows', 'pardee', 'yolo', 'hanford', 'cecil', 'sycamore', 'KLAMATH', 'MOGLIA', 'vleck', 'drummer', 'CANEYHEAD', 'musick', 'sierra', 'HAYNER', 'zook', 'argonaut', 'PALAU')
# get these soil series
s <- fetchOSD(s.list)
# manually convert Munsell -> sRGB
rgb.data <- munsell2rgb(s$hue, s$value, s$chroma, return_triplets = TRUE)
s$r <- rgb.data$r
s$g <- rgb.data$g
s$b <- rgb.data$b
# check
par(mar=c(0, 0, 0, 1))
plotSPC(s, name.style = 'center-center', width = 0.33)
Look at full range of OSD colors in this set.
Colors, arranged by ΔE00.
previewColors(s$soil_color)
rgb.colors <- munsell2rgb(s$hue, s$value, s$chroma, return_triplets = TRUE)
lab.colors <- as(sRGB(rgb.colors[['r']], rgb.colors[['g']], rgb.colors[['b']]), 'LAB')@coords
cols <- cbind(rgb.colors, lab.colors)
cols <- na.omit(cols)
cols <- as.data.frame(cols)
pairs(~ L + A + B, data=cols, pch=16, cex=2, col=rgb(cols$r, cols$g, cols$b))
Compute proportions of white, red, green, yellow, and blue “pigments” based on the CIE LAB representation of soil colors distributed over horizons, weighted by horizon thickness. Pigment proportions are used so that shallow soils can be compared with deep soils. Each row is an observation, columns describe the multivariate soil color signature.
# what is appropriate rescaling of L?
pig <- soilColorSignature(s, RescaleLightnessBy = 5, method = 'colorBucket')
knitr::kable(head(pig), digits = 3, row.names = FALSE)
id | .white.pigment | .red.pigment | .green.pigment | .yellow.pigment | .blue.pigment |
---|---|---|---|---|---|
AMADOR | 0.311 | 0.124 | 0.000 | 0.564 | 0.000 |
ARGONAUT | 0.159 | 0.328 | 0.000 | 0.513 | 0.000 |
CANEYHEAD | 0.560 | 0.061 | 0.050 | 0.330 | 0.000 |
CECIL | 0.120 | 0.413 | 0.000 | 0.467 | 0.000 |
DRUMMER | 0.473 | 0.103 | 0.004 | 0.417 | 0.003 |
HANFORD | 0.244 | 0.162 | 0.000 | 0.594 | 0.000 |
# move row names over for distance matrix
row.names(pig) <- pig[, 1]
d <- daisy(pig[, -1], stand = FALSE)
dd.colorBucket <- diana(d)
par(mar=c(0,0,1,1))
plotProfileDendrogram(s, dd.colorBucket, dend.y.scale = 1.18, scaling.factor = 0.0037, y.offset = 0.06, width = 0.33, cex.names = 0.45, shrink = TRUE, name.style = 'center-center', max.depth = 210)