Description Usage Arguments Details Value Author(s) See Also Examples
Summarize soil color data, weighted by occurrence and horizon thickness.
1 | aggregateColor(x, groups = "genhz", col = "soil_color")
|
x |
a |
groups |
the name of a horizon or site attribute used to group horizons, see examples |
col |
the name of a horizon-level attribute with soil color specified in hexadecimal (i.e. "#rrggbb") |
Weights are computed by:
w_i = sqrt(sum(thickness_i)) * n_i
where w_i is the weight associated with color i, thickness_i is the total thickness of all horizons associated with the color i, and n_i is the number of horizons associated with color i. Weights are computed within groups specified by groups
.
A list with the following components:
scaled.data |
a list of colors and associated weights, one item for each generalized horizon label with at least one color specified in the source data |
aggregate.data |
a data.frame of weighted-mean colors, one row for each generalized horizon label with at least one color specified in the source data |
D.E. Beaudette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # load some example data
data(sp1, package='aqp')
# upgrade to SoilProfileCollection and convert Munsell colors
sp1$soil_color <- with(sp1, munsell2rgb(hue, value, chroma))
depths(sp1) <- id ~ top + bottom
site(sp1) <- ~ group
# generalize horizon names
n <- c('O', 'A', 'B', 'C')
p <- c('O', 'A', 'B', 'C')
sp1$genhz <- generalize.hz(sp1$name, n, p)
# aggregate colors over horizon-level attribute: 'genhz'
a <- aggregateColor(sp1, 'genhz')
# aggregate colors over site-level attribute: 'group'
a <- aggregateColor(sp1, 'group')
# aggregate colors over depth-slices
s <- slice(sp1, c(5, 10, 15, 25, 50, 100, 150) ~ soil_color)
s$slice <- paste0(s$top, ' cm')
a <- aggregateColor(s, 'slice')
## Not run:
# optionally plot with helper function
if(require(sharpshootR))
aggregateColorPlot(a)
## End(Not run)
# a more interesting example
## Not run:
data(loafercreek, package = 'soilDB')
# generalize horizon names using REGEX rules
n <- c('Oi', 'A', 'BA','Bt1','Bt2','Bt3','Cr','R')
p <- c('O', '^A$|Ad|Ap|AB','BA$|Bw',
'Bt1$|^B$','^Bt$|^Bt2$','^Bt3|^Bt4|CBt$|BCt$|2Bt|2CB$|^C$','Cr','R')
loafercreek$genhz <- generalize.hz(loafercreek$hzname, n, p)
# remove non-matching generalized horizon names
loafercreek$genhz[loafercreek$genhz == 'not-used'] <- NA
loafercreek$genhz <- factor(loafercreek$genhz)
a <- aggregateColor(loafercreek, 'genhz')
# plot results with helper function
par(mar=c(1,4,4,1))
aggregateColorPlot(a, print.n.hz = TRUE)
# inspect aggregate data
a$aggregate.data
## End(Not run)
|
This is aqp 1.10
Loading required package: sharpshootR
genhz munsell.hue munsell.value munsell.chroma munsell.sigma col
1 A 5YR 3 4 0.029771789 #694628
2 BA 2.5YR 3 4 0.071290531 #734C2D
3 Bt1 7.5YR 4 5 0.041072698 #7B512F
4 Bt2 7.5YR 4 5 0.016509536 #855532
5 Bt3 2.5YR 4 6 0.048991327 #8F5E39
6 Cr 10YR 5 5 0.001899109 #997544
red green blue n
1 0.4109907 0.2727869 0.1579144 20
2 0.4502043 0.2976214 0.1781636 11
3 0.4836490 0.3167008 0.1842734 20
4 0.5213726 0.3341825 0.1945891 23
5 0.5611859 0.3687704 0.2223375 17
6 0.6000000 0.4588235 0.2666667 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.