diff --git a/articles/Introduction-to-SoilProfileCollection-Objects.html b/articles/Introduction-to-SoilProfileCollection-Objects.html index d5a57cc26..e2af2985b 100644 --- a/articles/Introduction-to-SoilProfileCollection-Objects.html +++ b/articles/Introduction-to-SoilProfileCollection-Objects.html @@ -364,8 +364,8 @@
#> [1] 21 27 32 55 25 34 3 15 27 32 25 31 33 13 21 23 15 17 12 19 14 14 22 25 40 51 67 24 25 32
sp4$elevation # vector of simulated elevation (site data)
#> [1] 1243.8475 911.6685 1260.0143 1023.6433 955.5042 976.4431 760.9843 1140.7615 815.0438
-#> [10] 964.1241
+#> [1] 1117.0541 1203.1636 839.1829 988.4573 854.7410 1024.3984 943.3412 1151.8720 811.1400
+#> [10] 882.6072
# unit-length value explicitly targeting site data
site(sp4)$collection_id <- 1
@@ -421,12 +421,12 @@ Horizon and Site Data#>
#> ----- Sites (6 / 10 rows | 5 / 5 columns) -----
#> id elevation collection_id constant group
-#> colusa 1243.8475 1 1 A
-#> glenn 911.6685 1 1 B
-#> kings 1260.0143 1 1 A
-#> mariposa 1023.6433 1 1 B
-#> mendocino 955.5042 1 1 A
-#> napa 976.4431 1 1 B
+#> colusa 1117.0541 1 1 A
+#> glenn 1203.1636 1 1 B
+#> kings 839.1829 1 1 A
+#> mariposa 988.4573 1 1 B
+#> mendocino 854.7410 1 1 A
+#> napa 1024.3984 1 1 B
#> [... more sites ...]
#>
#> Spatial Data:
@@ -585,16 +585,16 @@ Spatial Data# extract coordinates as matrix
getSpatial(sp4)
#> x y
-#> [1,] 353973.8 4109735
-#> [2,] 353793.7 4109693
-#> [3,] 353989.8 4109477
-#> [4,] 354039.0 4109567
-#> [5,] 354128.1 4109486
-#> [6,] 353967.1 4109475
-#> [7,] 354114.3 4109455
-#> [8,] 354157.6 4109561
-#> [9,] 354059.2 4109550
-#> [10,] 353882.0 4109505
+#> [1,] 354084.2 4109570
+#> [2,] 354017.7 4109469
+#> [3,] 354007.6 4109562
+#> [4,] 354018.7 4109498
+#> [5,] 353996.5 4109524
+#> [6,] 353991.1 4109616
+#> [7,] 354017.6 4109486
+#> [8,] 353854.3 4109652
+#> [9,] 354019.4 4109427
+#> [10,] 353895.3 4109604
# get/set spatial reference system using prj()<-
prj(sp4) <- '+proj=utm +zone=11 +datum=NAD83'
@@ -1640,13 +1640,13 @@ Aggregation over “slabs”# note: horizon names are lost due to aggregation
head(d.gsm, 7)
#> variable id value contributing_fraction top bottom
-#> 1 p1 1 5.920824 1.000 0 5
-#> 2 p1 1 5.921766 1.000 5 15
-#> 3 p1 1 5.934649 1.000 15 30
-#> 4 p1 1 6.176824 1.000 30 60
-#> 5 p1 1 8.192801 0.525 60 100
-#> 6 p1 1 NaN 0.000 100 200
-#> 7 p1 2 6.186225 1.000 0 5
+#> 1 p1 1 22.20121 1.000 0 5
+#> 2 p1 1 22.20124 1.000 5 15
+#> 3 p1 1 22.23549 1.000 15 30
+#> 4 p1 1 26.59446 1.000 30 60
+#> 5 p1 1 23.13158 1.000 60 100
+#> 6 p1 1 22.43933 0.125 100 200
+#> 7 p1 2 22.94254 1.000 0 5
A simple graphical comparison of the original and re-aligned soil
profile data, after converting slab()
result from long
-> wide format with {data.table} dcast()
:
col2Munsell()
generalizes and replaces rgb2munsell()
(thanks Shawn Salley for the suggestion)warpHorizons()
for warping horizon thickness (inflate/deflate) (thanks Shawn Salley for idea / inspiration)plotColorMixture()
when final mixed color does not exist in spectral librarygroupedProfilePlot()
+profileInformationIndex()
(vignette pending)Simulate Soil Colors
Matrix/data.frame-like access to profiles and horizons in a SoilProfileCollection
A simple index of "information" content associated with individuals in a SoilProfileCollection
object. Information content is quantified by number of bytes after gzip compression via memCompress()
.
A simple index of "information" content associated with individuals in a SoilProfileCollection
object. Information content is quantified by number of bytes after compression via memCompress()
.
logical, compute ratio to "baseline" information content, see details
logical, include horizon depths in vars
integer, number of significant digits to retain in numeric -> character conversion
remove NA before compression
pad all profiles with NA to deepest lower depth in x
(max(x)
)
-# simulate three profiles of increasing complexity
-p1 <- data.frame(id = 1, top = 0, bottom = 100, p = 5)
+# single horizon, constant value
+p1 <- data.frame(id = 1, top = 0, bottom = 100, p = 5, name = 'H')
+# multiple horizons, constant value
p2 <- data.frame(
-id = 2, top = c(0, 10, 20, 30, 40, 50),
-bottom = c(10, 20, 30, 40, 50, 100),
-p = rep(5, times = 6)
+ id = 2, top = c(0, 10, 20, 30, 40, 50),
+ bottom = c(10, 20, 30, 40, 50, 100),
+ p = rep(5, times = 6),
+ name = c('A1', 'A2', 'Bw', 'Bt1', 'Bt2', 'C')
)
+# multiple horizons, random values
p3 <- data.frame(
-id = 3, top = c(0, 10, 20, 30, 40, 50),
-bottom = c(10, 20, 30, 40, 50, 100),
-p = c(1, 5, 10, 3, 6, 2)
+ id = 3, top = c(0, 10, 20, 30, 40, 50),
+ bottom = c(10, 20, 30, 40, 50, 100),
+ p = c(1, 5, 10, 35, 6, 2),
+ name = c('A1', 'A2', 'Bw', 'Bt1', 'Bt2', 'C')
)
+# multiple horizons, mostly NA
+p4 <- data.frame(
+ id = 4, top = c(0, 10, 20, 30, 40, 50),
+ bottom = c(10, 20, 30, 40, 50, 100),
+ p = c(1, NA, NA, NA, NA, NA),
+ name = c('A1', 'A2', 'Bw', 'Bt1', 'Bt2', 'C')
+)
+
+# shallower version of p1
+p5 <- data.frame(id = 5, top = 0, bottom = 50, p = 5, name = 'H')
+
# combine and upgrade to SPC
-z <- rbind(p1, p2, p3)
+z <- rbind(p1, p2, p3, p4, p5)
depths(z) <- id ~ top + bottom
+hzdesgnname(z) <- 'name'
+
+z <- fillHzGaps(z)
# visual check
-plotSPC(z, color = 'p')
-
+par(mar = c(1, 0, 3, 3))
+plotSPC(z, color = 'p', name.style = 'center-center', cex.names = 0.8, max.depth = 110)
+
+# factor version of horizon name
+z$fname <- factor(z$name)
-# compute information index several ways
-profileInformationIndex(z, vars = c('p'), method = 'sum')
-#> 1 2 3
-#> 3.000000 4.375566 4.804137
-profileInformationIndex(z, vars = c('p'), method = 'mean')
-#> 1 2 3
-#> 0.0000000 0.4585219 0.6013790
+vars <- c('p', 'name')
+# result is total bytes
+pi <- profileInformationIndex(z, vars = vars, method = 'sum', baseline = FALSE)
-profileInformationIndex(z, vars = c('p'), method = 'mean', baseline = FALSE)
-#> 1 2 3
-#> 8.666667 19.666667 22.333333
-profileInformationIndex(z, vars = c('p'), method = 'sum', baseline = FALSE)
-#> 1 2 3
-#> 29 62 70
+text(x = 1:5, y = 105, labels = pi, cex = 0.85)
+mtext('Profile Information Index (bytes)', side = 1, line = -1)
+
# S4 method for SoilProfileCollection,ANY,ANY,ANY
+ # S4 method for SoilProfileCollection
[(x, i, j, ..., drop = TRUE)