# 2 Applications

## 2.1 Setup

``````library(aqp)
library(soilDB)
library(farver)
library(cluster)
library(ape)
library(colorspace)
library(latticeExtra)
library(knitr)
library(MASS)
library(vegan)
library(viridisLite)
library(tactile)``````

## 2.2 Core Functions

Soil Survey Technical Note 2

### 2.2.1 Color Contrast Metrics

Compute several indices of color contrast from 2 vectors of Munsell colors, `m1` and `m2`. Comparisons fully vectorized, e.g.Â comparisons performed element-wise \(m1_i ~\leftrightarrow~ m2_i\) \(...\) \(m1_n ~\leftrightarrow~ m2_n\).

• \(dH\): change in Munsell hue, see Hue Position section below
• \(dV\): change in Munsell value (absolute value of difference)
• \(dC\): change in Munsell chroma (absolute value of difference)
• \(\Delta{E_{00}}\): CIE2000 Delta-E #1, #2
• \(cc\): soil color contrast class (Soil Survey Technical Note 2)

Results as a `data.frame`.

``````# examples
m1 <- c('10YR 6/3', '7.5YR 3/3', '10YR 2/2', '7.5YR 3/4')
m2 <- c('5YR 3/4', '7.5YR 4/4', '2.5YR 2/2', '7.5YR 6/3')

# result is a data.frame
d <- colorContrast(m1, m2)

# check
kable(d, row.names=FALSE)``````
m1 m2 dH dV dC dE00 cc
10YR 6/3 5YR 3/4 2 3 1 31.313572 Prominent
7.5YR 3/3 7.5YR 4/4 0 1 1 9.647979 Faint
10YR 2/2 2.5YR 2/2 3 0 0 6.814101 Faint
7.5YR 3/4 7.5YR 6/3 0 3 1 30.265956 Distinct

Results summarized in a figure.

``````# more examples
m1 <- c('10YR 6/3', '7.5YR 3/3', '10YR 2/2', '7.5YR 3/4', '2.5Y 6/8', '5B 4/6')
m2 <- c('5YR 3/4', '7.5YR 4/4', '2.5YR 2/2', '7.5YR 6/3', '10YR 2/1', '5GY 3/4')

# graphical comparison
colorContrastPlot(m1, m2)``````

Simulated redoximorphic feature colors, contrast classes and \(\Delta{E_{00}}\).

``````m1 <- paste0('7.5YR 4/', 2:8)
m2 <- rep('10YR 5/2', times=length(m1))
colorContrastPlot(m1, m2, labels = c('F3M', 'MAT'), d.cex = 0.8, col.cex = 0.8)``````

``````m1 <- paste0('5Y 4/', 5:1)
m2 <- rep('10YR 3/5', times=length(m1))
colorContrastPlot(m1, m2, labels = c('RMX/FED', 'MAT'), d.cex = 0.8, col.cex = 0.8)``````

``````m1 <- c('2.5Y 3/2', '5Y 3/2', '2.5GY 3/2', '5GY 3/2', '7.5BG 3/2', '2.5B 3/2')
m2 <- rep('10YR 3/5', times=length(m1))
colorContrastPlot(m1, m2, labels = c('RMX', 'MAT'), d.cex = 0.8, col.cex = 0.8)``````