-
Notifications
You must be signed in to change notification settings - Fork 0
/
RaCA_Supplement_submit_wcode_NatureStyleBIB.Rmd
2497 lines (2008 loc) · 115 KB
/
RaCA_Supplement_submit_wcode_NatureStyleBIB.Rmd
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: 'Supplement for RaCA: SOC in CONUS, a reporoducible baseline'
author: "Wills and Loecke"
date: "March 5 2018"
output:
pdf_document: default
#toc: true
header-includes:
- \renewcommand{\caption}{Fig.}
- \usepackage{caption}
bibliography: RaCAbib2.bib
csl: nature.csl
---
\captionsetup[table]{labelformat=empty}
# RaCA study design and data analysis
##Introduction
This document is a supplement to the **Rapid Carbon Assessment: A baseline soil organic carbon pool for CONUS with refinements in confidence and understanding**. This document was produced with knitR as an R markdown file. It is exported as an html and pdf document. A breif description of each phase of data analysis is given followed by the R script used to execute. Some portions (data and devTools download) are best done once outside the rmd file. Update rmd file with desired path to execute.
```{r setup, include=TRUE, echo=T, message=F}
require("knitr")
knitr::opts_chunk$set(echo = T, comment = "#", warning = FALSE,
message = FALSE, error =FALSE, eval=T,
tidy.opts=list(width.cutoff=60),tidy=TRUE)
#To use this script, update with paths
#Set working directory to the desired location to download RaCA data
workdir <- setwd(getwd()) # personalize the working directory for each user.
opts_knit$set(root.dir = workdir)
rm(list=ls()) #clear previous data
list.of.packages <- c("ggplot2", "plyr", "Rcpp", "RColorBrewer",
"lattice", "aqp", "stringr", "reshape2", "ggthemes",
"tidyverse", "RCurl", "Hmisc", "gridExtra", "ggmosaic",
"png","rstan","lme4", "printr", "dplyr","tidyr",
"StanHeaders")
new.packages <- list.of.packages[!(list.of.packages %in%
installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
library(ggplot2)
library(Rcpp)
library(plyr)
library(RColorBrewer)
library(lattice)
library(stringr)
library(reshape2)
library(ggthemes)
library(RCurl)
library(rstan)
library(lme4)
library(printr)
```
###Experimental design
A full description of the design, protocols and methodology can be found at the Rapid Carbon Assessment website [@soilsurveystaffrapid2017]. Briefly, a multi-level stratified random sampling scheme was used to allocate soil pedons across the conterminous United States (CONUS) to capture the range, central tendency and variability across all soil types and land use - land cover classes. All areas of CONUS with National Cooperative Soil Survey maps, documented in the Soil Survey Geographic Database (known as SSURGO) as of January 2012 [@gSSURGO2013] were part of the sampling domain. Strata were created by regions (defined by the 2010 Major Land Resource Area Regional Office Areas, in the National Soil Survey Handbook [@us_department_of_agriculture_natural_resources_conservation_service_national_nodate], groups of soils with similar expected SOC (as described by Wills et al.[@Wills2013]), and land use - land cover classes as defined by the National Resource Inventory (NRI; [@UnitedStatesDepartmentofAgriculture2007]) which were represented spatially by linked classes in the National Land Cover Dataset (NLCD[@Fry2011]). The combination of land use - land cover class and soil group is referred to as LUGR and was used to distribute and aggregate pedon data. The NRI sampling framework [@Nusser1998] was used to distribute sites or locations for sampling within each LUGR strata.
### RaCA data source
Data analysis begins with the basic sample data available via USDA/NRCS box accounts or through the RaCA website.
This section may be used to directly download data (set the working directory to your desired location in the setup portion of the rmd file). Otherwise, the data, basic summary and metadata can be accessed at the [RaCA website](https://www.nrcs.usda.gov/wps/portal/nrcs/detail/soils/survey/?cid=nrcs142p2_054164).
```{r data, eval=T, echo = T, warning = F, message = F, include=F, results='hide', cache=T}
raca.samp.url <- 'https://nrcs.box.com/shared/static/1huwn8z1ulpyylnfgj920twpua0rfjp3.csv'
if(!file.exists('RaCA_samples.csv'))
download.file(raca.samp.url, destfile = 'RaCA_samples.csv')
samp <- read.csv("RaCA_samples.csv", na.strings = c("NA", "NULL"))
#pixel counts from 30m grid of gSSURGO and NLCD used to calculate weights
raca.lugr.wt.url <- 'https://nrcs.box.com/shared/static/c5zerrrhum9uyvxdx93nq6p1mqx8cqg7.csv'
if(!file.exists('LUGR_pixelcount30m_label.csv'))
download.file(raca.lugr.wt.url,
destfile = 'LUGR_pixelcount30m_label.csv')
LUGR_wt <- read.csv("LUGR_pixelcount30m_label.csv")
#region area from NRCS MO polygon (2008)
raca.region.url <- 'https://nrcs.box.com/shared/static/k568mkg4ge11rncqvfpcl9bgl85ohgi6.csv'
if(!file.exists('raca_region.csv '))
download.file(raca.region.url ,
destfile = 'RaCA_region.csv')
region <- read.csv("RaCA_region.csv")
# previous estimates of CONUS SOC from the literature
conus_SOC_previous_url <- 'https://nrcs.box.com/shared/static/9a3vquaf8o3jiq9k5tfqixbd4p1e91xe.xlsx'
ifelse(!file.exists('CONUS_SOC_previous_estimates.xlsx'),
download.file(conus_SOC_previous_url,
destfile = 'CONUS_SOC_previous_estimates.xlsx') ,
"File already downloaded")
```
###Field sampling protocols
A randomized list of target sites was supplied to NRCS soil scientists as x-y coordinates. Land use -land cover class and soil group were verified remotely and again upon sample collection. All site, pedon, data and sample collection were done with a common set of protocols [@soilsurveystaffrapid2017]. All protocols (including instructions for moving dangerous or inaccessible sites) and data collected are available at the RaCA website [@soilsurveystaffrapid2017]. Additional information on general vegetation, bare ground and satellite pedons (four pedons 30m away in each cardinal direction, sampled but not analyzed in the laboratory) is available, but was not used for this project/manuscript. As near as possible to the x,y coordinates, small pits were excavated to a depth of 50 centimeters or to a root-limiting layer, such as bedrock or cemented soil. Each pedon was described according to the "Field Book for Describing and Sampling Soils" [@schoeneberger2012]. Minimum required information for each horizon included: horizon designation, depths, color, texture, rock fragment modifier (percent coarse fragments by volume), redoximorphic features, and structure (where possible). Samples were collected from the surface to a depth of 5 centimeters and from 5 to 50 centimeters by genetic horizon. Probes or augers were used to sample genetic horizons from 50 to 100 centimeters. Volumetric samples were collected for samples from the surface to a depth of 50 centimeters in the most appropriate manner [@soilsurveystaffrapid2017]. Samples were labeled, sealed in air-tight bags, and transported to the soil survey regional office for processing.
###Sample analyses
All samples were transported to regional soil survey offices and processed to <2mm and air dried. Samples from the central pedon were shipped to the Kellogg Soil Survey Laboratory where combustion soil organic carbon and calcimeter inorganic carbon were done according to the Soil Survey Laboratory Methods Manual [@KelloggSoilMethods2014].
For each sample, SOC was defined as the difference between total carbon and inorganic carbon (See RaCA Data Preparation, this document). Bulk density was calculated using the total air dry weight of each sample, corrected for the weight of coarse fragments greater than 2mm and for any remaining water weight and the known sample volume. For samples without known volume, bulk density was modelled using the random forest approach described by Sequeira et al. [-@Sequeira2014]. The models used and predictions generated are available at the RaCA website. The amount of soil material within in each given layer or horizon was corrected using a volumetric determination of coarse fragments during pedon description [@schoeneberger2012].
### RaCA Data Preparation
A set of rules was developed to clean and organize data. This included rules for inclusion (values that are theoretically possible), matching field and laboratory data records and checking that locations were within scope of the sampling scheme. At this point, SOC concentration, bulk density and SOC density by sample were calculated. All data manipulation and calculations were done in R [@RCoreTeam2017]. Some variables are renamed for ease of script writing and reading. Explanation of data columns is available here, from the [RaCA website](https://www.cloudvault.usda.gov/index.php/s/yvAPDc3wBZTdwU2).
```{r dataprep, warning = F, message = F, error = F }
#limit calculations to central pedons that have laboratory data
samp <- samp[samp$pedon_no == 1,]
#count sites by land use and region
#MO is an abbreviation for RaCA Region
# and LU is the abbreviation for Land Use/Land Cover class
agg.sites <- aggregate(data=samp, rcasiteid ~ MO + LU , function(x) length(unique(x)))
names(agg.sites)[3]<- "Count"
Count.sites <- reshape(agg.sites,idvar="MO", timevar = "LU", direction = "wide" )
colnames(Count.sites) <- c("MO","Cropland","Forestland","Pastureland",
"Rangeland","Wetland","CRP")
knitr::kable(Count.sites, caption = "Table S1. Count of Sites by LU/LC and Region")
#simplify variables and calculate SOC density for each sample
samp$CALC_SOC <- ifelse(!is.na(samp$caco3),
ifelse(samp$caco3>0,samp$c_tot_ncs-(samp$caco3*0.12),samp$c_tot_ncs),
samp$c_tot_ncs)
samp$SOC <- ifelse(samp$CALC_SOC<0, 0, samp$CALC_SOC)
samp$BD <- ifelse(is.na(samp$Measure_BD), samp$Model_BD,
#use modeled value if there is no measured BD
ifelse(samp$M == "O", ifelse(samp$Measure_BD>1,
samp$Model_BD, samp$Measure_BD),
#use modeled value for impossibly high BD in organic horizons
ifelse(samp$Measure_BD>2, samp$Model_BD,
samp$Measure_BD)))
#if organic is high use model BD
samp$SOCd <- with(samp,SOC*BD)
samp$SOCden <- with(samp,SOC*BD*(1 - ifelse(fragvolc == 0, 0, fragvolc/100)))
samp$top <-samp$TOP
samp$bottom <- samp$BOT
samp$thick <- samp$bottom - samp$top
rm(agg.sites)
```
### RaCA Pedon - SOC stock calculation
The next step used cleaned sample data to calculate fixed depth increment SOC stocks by pedon. This includes assigning some metadata to screen pedons for appropriate completeness. Pedons that are missing samples are not included in further analysis, excluding pedons that do not have samples from R, Cr, Bm or other root restricting layers. Data aggregation done with the plyr package [@Wickham2011].
Some variables are renamed for ease of script writing and reading.
```{r pedon}
#assign how layers are counted in stock calculations
#puts a number on the amount (cm) of each layer used in calculation
#there are more streamlined ways to do this but this method is maintained from
# previous work (it is also computationally simple and uses few computing resources)
library(plyr)
samp$SOC_5 <- ifelse(samp$bottom<=5, samp$thick,ifelse(samp$top<5, 5-samp$top,0))
samp$SOC_30 <- ifelse(samp$bottom<=30, samp$thick,
ifelse(samp$top<30, 30-samp$top,0))
samp$SOC_100 <- ifelse(samp$bottom<=100, samp$thick,
ifelse(samp$top<100, 100-samp$top,0))
#calculate layer stocks - assigned depth * SOCden
#native units are Mg/ha
samp$SOCstock5 <- with(samp, SOCden*SOC_5)
samp$SOCstock30 <- with(samp, SOCden*SOC_30)
samp$SOCstock100 <- with(samp, SOCden*SOC_100)
#sum SOC by pedon
SOC_5 <- aggregate(SOCstock5~MO + MOGr + LU + MOGrLU + rcasiteid
+ upedonid + upedon, data=samp, FUN=sum)
SOC_30 <- aggregate(SOCstock30~upedonid, data=samp, FUN=sum)
SOC_100 <-aggregate(SOCstock100~upedonid, data=samp, FUN=sum)
#additional information about pedons used to screen for pedons
# that do not meet depth requirements
#pedon id info
ped <- aggregate(sample.id ~MO + MOGr + LU + MOGrLU + rcasiteid
+ upedonid + upedon, data=samp, FUN=length)
names(ped)[8] <- "Sample_count"
#pedon information
pedon_thick <- aggregate(thick ~ upedonid, data=samp, FUN=sum)
names(pedon_thick)[2] <- "total_thickness"
ped_bott <- aggregate(bottom~upedonid, data=samp, FUN=max)
lab_no <- aggregate(natural_key~upedonid, data=samp, FUN=length)
names(lab_no)[2] <- "Lab_count"
sample_notR <- aggregate(sample.id~upedonid,
data=samp[grep("R",
samp$model_desg,
invert=T, ignore.case=T),] , FUN=length)
names(sample_notR)[2] <- "Non-R_SampleCount"
SOC_no <- aggregate(SOC~upedonid,
data=samp[!is.na(samp$SOC), ], FUN=length)
names(SOC_no)[2] <- "SOC_count"
SOC_thick <- aggregate(thick~upedonid,
data=samp[!is.na(samp$SOC), ], FUN=sum)
names(SOC_thick)[2] <- "SOC_thickness"
top <- aggregate(top~upedonid, data=samp, FUN=min)
names(top)[2] <- "Pedon_top"
#depth of R or other restrictive layer
# (assumed to have negligble SOC at this depth and below)
hard <- c("Bkm", "Bkmm", "Bqm", "R", "Cr", "m")
depthR <- aggregate(top~upedonid,
data=samp[grepl(paste(hard, collapse='|'),
samp$model_desg, ignore.case=T),],FUN=min)
names(depthR)[2] <- "Depth_to_R"
depth_O <- aggregate(thick~upedonid,
data=samp[samp$M == "O",], FUN=min)
names(depth_O)[2] <- "Depth_of_O"
depth_O$Depth_of_O <- ifelse(is.na(depth_O$Depth_of_O), 0, depth_O$Depth_of_O)
#combine pedon information
SOC5 <- join(ped, SOC_5, by="upedonid", type="full", match="first")
SOC30 <- join(SOC5, SOC_30, by="upedonid", type="full", match="first")
SOC100 <- join(SOC30,SOC_100, by="upedonid", type="full", match="first")
SOCp <- join(SOC100, pedon_thick, by="upedonid", type="full", match="first")
SOCn <- join(SOCp, SOC_no, by="upedonid", type="full", match="first")
SOCnn <- join(SOCn, lab_no, by="upedonid", type="full", match="first")
SOCpn <- join(SOCnn, depthR, by="upedonid", type="full", match="first")
SOCpp <- join(SOCpn, sample_notR, by="upedonid", type="full", match="first")
SOCpo <- join(SOCpp, depth_O, by="upedonid", type="full", match="first")
SOCpedons <- join(SOCpo, SOC_thick, by="upedonid", type="full", match="first")
#remove unneeded tables
rm(SOC5,SOC30, SOC100, SOCp, SOCn, SOCnn, SOCpp, SOCpo)
SOCpedons$USE <-ifelse(SOCpedons$SOCstock5 == 0,
ifelse(SOCpedons$SOC_count<SOCpedons$Lab_count,
"MISS_anal", "MISS_labsamp"),
ifelse(is.na(SOCpedons$total_thickness),'NA',
ifelse(SOCpedons$SOC_thickness>=SOCpedons$total_thickness, '100',
ifelse(!is.na(SOCpedons$Depth_to_R),
ifelse(SOCpedons$Depth_to_R <=SOCpedons$SOC_thickness , '100',
ifelse(SOCpedons$SOC_thickness >= 100, '100',
ifelse(SOCpedons$SOC_thickness >= 30, '30',
ifelse(SOCpedons$SOC_thickness >= 5, '5',
'NA')))),
ifelse(SOCpedons$SOC_thickness >= 100, '100',
ifelse(SOCpedons$SOC_thickness >= 30, '30',
ifelse(SOCpedons$SOC_thickness >= 5, '5', 'NA')))))))
# check NAs and missing samples
kable(table(SOCpedons$MO,SOCpedons$USE, useNA= "ifany"),
caption = "Table S2. Counts of missing samples by depth")
Use.pedons <- ddply(SOCpedons, .(MO), summarise,
N_5= sum(!is.na(SOCstock5)),
N_30= sum(!is.na(SOCstock30)),
N_100= sum(!is.na(SOCstock100))
)
#keep ones with values
SOCpedons <- SOCpedons[!is.na(SOCpedons$SOCstock5),]
SOCpedons <- SOCpedons[SOCpedons$SOCstock5 != 0,]
#remove stocks based on Use field
SOCpedons$SOCstock5 <- as.numeric(ifelse(SOCpedons$USE %in%
c(5, 30, 100),
SOCpedons$SOCstock5, ""))
SOCpedons$SOCstock30 <- as.numeric(ifelse(SOCpedons$USE
%in% c(30, 100),
SOCpedons$SOCstock30, ""))
SOCpedons$SOCstock100 <- as.numeric(ifelse(SOCpedons$USE
%in% c(100),
SOCpedons$SOCstock100, ""))
#limit pedon file to those that have useable data
SOCpedons <- SOCpedons[!is.na(SOCpedons$USE),]
#remove unwanted objects
rm(hard, depth_O, depthR, lab_no,ped, ped_bott, pedon_thick,
sample_notR, SOC_thick, SOC_100, SOC_30, SOC_5, SOC_no, SOCpn, top )
#export pedon (site) level SOC stocks
#############
write.table(SOCpedons,"RaCA_SOC_pedons.csv", sep=",", row.names=F)
```
## Data visualization
Graphs were produced with various packages within the statistical program R [@RCoreTeam2017] and implemented using R studio [@RStudioTeam2016]. The Algorithm for Quantitative Pedology (aqp, [@Beaudette2013] was used to evaluate properties by depth. Graphs, boxplots, stacked bar charts and density plots were created with ggplot2 [@Wickham2009] supplemented by gridExtra [@Auguie2017] and ggmosaic [@Jeppson2017].
Maps were created using ArcGIS __(ESRI Inc.)__ for compatibility with soil survey projects and servers.
###Sample properties by depth
The aqp package [@Beaudette2013] manipulates soil data by arranging pedons into common depth increments and aiding in visualization. The package was used to aggregate sample values by land use - land cover class and display the results by depth in the main text.
```{r depthplotPrep, eval=T}
require(aqp)
#filter samples to those that have land use/cover class with spatial extent
# written as LU does not equal X
x <- samp[samp$LU != "X",]
#use aqp package to treat groups of samples as pedons with locations and depths
# promote to soil profile
depths(x) <- upedon ~ TOP + BOT
# move some site-level data to site slot
site(x) <- ~ rcasiteid + MO + LU
# slice horizon samples into individual 1cm depth slices for calculation
# depth-wise quantiles, by LU
#because all pedons had a 0 -5cm sample collected and other depths were
# allowed to fluctuate, this creates some artifacts
a <- slab(x, LU ~ SOC + BD + SOCden)
# assign labels to LU factor levels
a$LU <- factor(a$LU, levels=c('C', 'F', 'P', 'R', 'W'),
labels=c('Cropland', 'Forestland', 'Pastureland',
'Rangeland', 'Wetland'))
# custom colors
tps <- list(superpose.line=list(col=c('Yellow',
'DarkGreen', "LightGreen",'DarkRed',
"RoyalBlue"), lwd=3))
p.SOC <- xyplot(top ~ p.q50, groups=LU, data=a,
ylab=list('Depth (cm)', cex= 1),
xlab=list('% SOC
\n Median (line) bounded by 25th and 75th percentiles (shaded)',
cex = .75),
lower=a$p.q25, upper=a$p.q75, ylim=c(100,-1),
panel=panel.depth_function, alpha=0.25, sync.colors=TRUE,
prepanel=prepanel.depth_function,
strip=strip.custom(bg=grey(0.85)),
scales=list(x=list(alternating=1)),
par.settings=tps, subset=variable == 'SOC',
auto.key=list(columns=3,
space = "top", just = .005,
lines=TRUE, points=FALSE, cex=.6),
xlim=c(0,40))
p.SOC.z <- xyplot(top ~ p.q50, groups=LU, data=a,
ylab='Depth (cm)',
xlab=list('% SOC \n Median (line) bounded by 25th and 75th percentiles (shaded)',
cex = 0.75),
lower=a$p.q25, upper=a$p.q75, ylim=c(50,-1),
panel=panel.depth_function, alpha=0.25, sync.colors=TRUE,
prepanel=prepanel.depth_function,
strip=strip.custom(bg=grey(0.85)),
scales=list(x=list(alternating=1)),
par.settings=tps, subset=variable == 'SOC',
auto.key=list(title ="Land Use - Land Cover Classes",
columns=3,
space = "top", just = 0.005, lines=TRUE,
points=FALSE, cex=.6),xlim=c(0,7.5)
)
p.BD <- xyplot(top ~ p.q50, groups=LU, data=a, ylab='Depth (cm)',
xlab=list('Bulk density (g cm-3)
\n Median (line) bounded by 25th and 75th percentiles (shaded)',
cex = .75),
lower=a$p.q25,
upper=a$p.q75,
ylim=c(100,-1),
panel=panel.depth_function,
alpha=0.25,
sync.colors=TRUE,
prepanel=prepanel.depth_function,
strip=strip.custom(bg=grey(0.85)),
scales=list(x=list(alternating=1)),
par.settings=tps, subset=variable == 'BD',
auto.key=list(columns=3,
space = "top", just = 0.005, lines=TRUE,
points=FALSE, cex=.6)
)
p.BD <- xyplot(top ~ p.q50, groups=LU, data=a, ylab='Depth (cm)',
xlab=list(expression(paste('Bulk density (g cm'^-3,')'),
'\n Median (line) bounded by 25th and 75th percentiles (shaded)'), cex = .75),
lower=a$p.q25,
upper=a$p.q75,
ylim=c(100,-1),
panel=panel.depth_function,
alpha=0.25,
sync.colors=TRUE,
prepanel=prepanel.depth_function,
strip=strip.custom(bg=grey(0.85)),
scales=list(x=list(alternating=1)),
par.settings=tps, subset=variable == 'BD',
auto.key=list(columns=3,
space = "top", just = 0.005, lines=TRUE, points=FALSE, cex=.6)
)
p.SOCden <- xyplot(top ~ p.q50, groups=LU, data=a, ylab='Depth (cm)',
xlab=list('SOC density (g cm-3)
\n Median (line) bounded by 25th and 75th percentiles (shaded)',
cex = .75),
lower=a$p.q25,
upper=a$p.q75,
ylim=c(50,-1),
panel=panel.depth_function,
alpha=0.25,
sync.colors=TRUE,
prepanel=prepanel.depth_function,
strip=strip.custom(bg=grey(0.85)),
scales=list(x=list(alternating=1)),
par.settings=tps, subset=variable == 'SOCden',
auto.key=list(title ="Land Use / Land Cover Classes", columns=3,
space = "top", just = 0.005,
lines=TRUE, points=FALSE, cex=.6)
)
```
#### Fig S1. Plots of a) SOC concentrations, b) SOC concentrations on an alternate scale, c) bulk density and d) SOC density by depth.
```{r depthplot, eval=T}
#display graphs
p.SOC
p.SOC.z
p.BD
p.SOCden
#remove data from this chunk
rm(x,a, tps)
#remove package that may interfere with other commands
detach("package:aqp", unload=TRUE)
```
###Evaluate Stocks by Land Use - Land Cover Class
Initially, simple summaries of SOC stocks by depth increment were evaluated by land use -land cover class and region. Region and land use are conflated as class presence and contribution to SOC pool varies by Region see Loecke and Soil Survey Staff [@soilsurveystaffrapid2017] for more information. While there are small differences in average stocks between land use - land cover classes, they are not statistically or meaningfully significant.
#### Fig S2. Boxplots of SOC stocks by land use - land cover class
``` {r supp_box, eval=T, fig.height = 3}
knitr::opts_chunk$set(echo = T, comment = "#", message=FALSE, warning = FALSE)
SOCpedons <- read.csv("RaCA_SOC_pedons.csv", stringsAsFactors = F)
#only include pedons with valid stock calculations to 100cm
S <- SOCpedons[!is.na(SOCpedons$SOCstock100),]
S$MO <- factor(S$MO)
#check levels of LULC; change and relabel if needed
#levels(S$LU)
S$LU <- factor(S$LU, levels=c('C', 'F', 'P', 'R', 'W', 'X'),
labels=c('Cropland', 'Forestland',
'Pastureland', 'Rangeland', 'Wetland', 'CRP'))
#CRP - Conservation Reserve Program
#Create Boxplots for 100cm SOC stocks
s <- na.omit(S[ ,c("LU","MO","SOCstock100")])
#limit data used to those with relevant values
B <- ggplot(s, aes(y =SOCstock100, x = LU)) + geom_boxplot()
Bl <- B + labs(x ="\n Land Use - Land Cover Class \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 100cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#Create Boxplots for 30cm SOC stocks
s30 <- na.omit(S[,c("LU","MO","SOCstock30")])
#limit data used to those with relevant values
B30 <- ggplot(s30, aes(y =SOCstock30, x = LU)) + geom_boxplot()
B30l <- B30 + labs(x ="\n Land Use - Land Cover Class \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 30cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#Create Boxplots for 5cm SOC stocks
s5 <- na.omit(S[,c("LU","MO","SOCstock5")])
#limit data used to those with relevant values
B5 <- ggplot(s5, aes(y =SOCstock5, x = LU)) + geom_boxplot()
B5l <- B5 + labs(x ="\n Land Use - Land Cover Class \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 5cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#print plots
Bl
B30l
B5l
```
SOC stocks are not normally distributed across or within land use -land cover classes.Converting SOC stocks by natural log creates a distribution more suitable for statistical comparison.
#### Fig. S3. Distribution of SOC stocks by land use - land cover class
``` {r dist, eval=T, cache=T}
knitr::opts_chunk$set(echo = T, comment = "#", message=FALSE, warning = FALSE)
# the distribution of SOC stocks in not normal
dist <- ggplot(S, aes(x =SOCstock100)) +
geom_density(aes(fill=LU), alpha = 0.5)+
labs(fill ="Land Use - Land Cover Class",
x=expression(paste("SOC stock (Mg ha"^-1,") to 100cm")))
#see implementation ggplot development package for a better visual of distribution by land use class
#https://raw.githubusercontent.com/ncss-tech/soil-pit/master/sandbox/skye/joy_plots.R
dist
dist_logx <- ggplot(S, aes(x =SOCstock100)) +
geom_density(aes(fill=LU), alpha = 0.5)+
labs(fill ="Land Use - Land Cover Class",
x=expression(paste("SOC stock (Mg ha"^-1,") to 100cm")))+
scale_x_log10()
#see implementation ggplot development package for a better visual of distribution by land use class
#https://raw.githubusercontent.com/ncss-tech/soil-pit/master/sandbox/skye/joy_plots.R
dist_logx
```
#### Fig. S4. Boxplots on a log scale of SOC stocks by land use - land cover class
``` {r logbox, eval=T, fig.height = 4, cache=T}
knitr::opts_chunk$set(echo = T, comment = "#", message=FALSE, warning = FALSE)
#Modify scales to log for each depth increment
B5L <- B5 +
labs(x ="\n", y=expression(paste("SOC stock (ln Mg ha"^-1,") to 5cm"))) +
scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
B30L <- B30 + labs(x ="\n Land Use - Land Cover Class \n",
y=expression(paste("SOC stock (ln Mg ha"^-1,") to 30cm"))) +
scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
BL <- B +
labs(x ="\n Land Use - Land Cover Class \n",
y=expression(paste("SOC stock (ln Mg ha"^-1,") to 100cm"))) +
scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#print log plots
B5L
B30L
BL
```
#### Fig. S5. Boxplots on a log scale of SOC stocks by Region
``` {r logbox2, eval=T, fig.height = 4, cache=T}
knitr::opts_chunk$set(echo = T, comment = "#", message=FALSE, warning = FALSE)
#Create Boxplots for 100cm SOC stocks
Br <- ggplot(s, aes(y =SOCstock100, x= MO)) +
geom_boxplot()
Brl <- Br +
labs(x ="\n RaCA Region \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 100cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
Br30 <- ggplot(s30, aes(y =SOCstock30, x = MO)) +
geom_boxplot()
Br30l <- Br30 +
labs(x ="\n RaCA Region \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 30cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
Br5 <- ggplot(s5, aes(y =SOCstock5, x = MO)) +
geom_boxplot()
Br5l <- Br5 +
labs(x ="\n RaCA Region \n",
y=expression(paste("SOC stock (Mg ha"^-1,") to 5cm"))) +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#Modify scales to log for each depth increment
Br5L <- Br5 +
labs(x ="\n RaCA Region \n",
y=expression(paste("SOC stock (ln Mg ha"^-1,") to 5cm"))) +
scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
Br30L <- Br30 +
labs(x ="\n RaCA Region \n",
y=expression(paste("SOC stock (ln Mg ha"^-1,") to 30cm"))) + scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
BrL <- Br +
labs(x ="\nRaCA Region\n",
y=expression(paste("SOC stock (ln Mg ha"^-1,") to 100cm"))) +
scale_y_log10() +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=8),legend.text=element_text(size=12))
#print log plots
Br5L
Br30L
BrL
rm(s,S,s30,s5,B, Bl, B30, B30l, B5, B5l, Br, Brl, Br30, Br30l, Br5, Br5l )
```
An alternate visualization method is to segment SOC stocks by additive depth increments then visualize those increments as a total sums on a chart. Aggregating by overall land use - land cover class mean emphasizes the differences between land use - land cover classes. Individual pedons are also important to consider, as individual region x land use-land cover class interactions show differences in the highest and lowest value pedons. This will be important to consider as the dataset is used for regional and local investigations. In Fig. S8, SOC pedon stocks to 100cm are sorted and ranked by both land use-land cover class and RaCA Region. The pedons with minimum, median (medoid) and maximum SOC stocks are displayed by region and land use - land cover classes. This represents the typical and extreme stocks found in various conditions.
#### Fig. S6. Stacked bar chart by Land Use - Land Cover Class
```{r stackplot, eval=T, cache=T}
#This section using an alternate scripting style with dplyr, tidyr and magrittr piping
# list.of.packages
detach(name=package:plyr, TRUE) #remove prior package to eliminate conflicts
#this section uses
library(dplyr)
library(tidyr)
SOCpedons <- read.csv("RaCA_SOC_pedons.csv", stringsAsFactors = F)
ped <- SOCpedons[,2:11] #reassign table form modification
#create factors for stacked bar plots
ped$zero_to_stock5 <- ped$SOCstock5
ped$five_to_stock30 <- ped$SOCstock30-ped$SOCstock5
ped$thirty_to_stock100 <- ped$SOCstock100- ped$SOCstock30
ped$LUGR <- as.factor(paste0(as.character(ped$LU),substr(ped$rcasiteid,2,5)))
# check LU order
#levels(ped$LU)
ped$LU <- as.factor(ped$LU)
ped$LU <- factor(ped$LU, levels(ped$LU)[c(5,2,3,4,1,6)])
#levels(ped$LU)
levels(ped$LU)<- c('Wetland', 'Forestland',
'Pastureland', "Rangeland", 'Cropland', 'CRP')
#calculate depth increment and land use means
td <- ped %>%
select(upedon, MO, LU, LUGR, zero_to_stock5, five_to_stock30, thirty_to_stock100) %>%
filter(LU != 'CRP') %>% #limit to land use/cover classes with spatial extent
gather(Depth, SOCstock, zero_to_stock5, five_to_stock30, thirty_to_stock100) %>%
arrange(upedon) %>%
group_by(LU, Depth) %>%
summarize(
N = length(SOCstock),
SOC = mean(SOCstock, na.rm=T),
SOCmed = median(SOCstock, na.rm=T),
sd = sd(SOCstock, na.rm=T),
se = sd/sqrt(N),
CI_l = SOC-(se*1.96),
CI_u = SOC+ (se*1.96),
q25 = quantile(SOCstock, .25, na.rm=T),
q75 = quantile(SOCstock, .75, na.rm=T)) %>%
mutate(ID = paste(LU, str_sub(Depth, -3, -1), sep ="_"))
#recalculate with stock totals (correct placement of error bars)
ti <- ped %>%
select(upedon, MO, LU, LUGR, SOCstock5, SOCstock30, SOCstock100) %>%
filter(LU != 'CRP') %>%
gather(Depth, SOCstock, SOCstock5, SOCstock30, SOCstock100) %>%
group_by(LU, Depth) %>%
summarize(
tN = length(SOCstock),
tSOC = mean(SOCstock, na.rm=T),
tsd = sd(SOCstock, na.rm=T),
tse = tsd/sqrt(tN),
lCI = tSOC-(tse*1.96),
uCI = tSOC+ (tse*1.96),
tq25 = quantile(SOCstock, .25, na.rm=T),
tq75 = quantile(SOCstock, .75, na.rm=T)) %>%
mutate(ID = paste(LU, str_sub(Depth, -3, -1), sep ="_"))%>%
mutate(Total = Depth)%>%
ungroup() %>%
select(-c(Depth, LU))
t <- inner_join(td,ti, by = "ID")
t$Depth <- as.factor(t$Depth)
t$Depth <- factor(t$Depth, levels(t$Depth)[c(3,1,2)]) #reorder factor levels
#levels(t$Depth)
levels(t$Depth) = c("0 to 5 cm","5 to 30 cm","30 to 100 cm") #relabel levels
#levels(t$LU)
d <- ggplot(t, aes(LU, SOC)) +
geom_col(aes(fill=factor(Depth, levels = rev(levels(Depth))))) +
scale_y_reverse() +
scale_fill_discrete(guide=guide_legend(reverse=T)) +
labs(x ="Land Use - Land Cover Class",
y=expression(paste("SOC stock (Mg ha"^-1,")")), fill = "Depth Increment") +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=10),legend.text=element_text(size=10)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
d
de <- ggplot(t, aes(LU, SOC)) +
geom_col(aes(fill=factor(Depth, levels = rev(levels(Depth))))) +
scale_y_reverse() +
scale_fill_discrete(guide=guide_legend(reverse=T)) +
geom_errorbar(aes(ymax=uCI , ymin= lCI), width = 0.08,
color = "black", size = 0.1) +
ggtitle("SOC stocks by Depth Increment") +
labs(x ="Land Use - Land Cover Class",
y=expression(paste("SOC stock (Mg ha"^-1,")")),
fill = "Depth Increment") +
theme(axis.text.y=element_text(size=12),
axis.text.x=element_text(size=10),legend.text=element_text(size=10)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
de
# reproduced with median and error bars representing credible intervals
# from hierarchical Bayesian analysis (this document)
rm(t,td,ti)
```
#### Fig S7. Pedons SOC Stock in Depth Increments. Selected pedons are characteristic of land Use - land cover class and raCA regions.
``` {r supp_ped, eval=T}
knitr::opts_chunk$set(echo = T, comment = "#", message=FALSE, warning = FALSE)
#use dplyer package (with piping) to select individual pedons for stacked plot display
library(tidyverse)
library(gridExtra)
#filter for only LU classes with spatial extent
O <- SOCpedons[SOCpedons$LU != "X", ]
O$LUGR <- as.factor(paste0(as.character(O$LU),substr(O$rcasiteid,2,5)))
O$LU <- as.factor(O$LU)
# check LU order
#levels(O$LU)9.
O$LU <- factor(O$LU, levels(O$LU)[c(5,2,3,4,1)])
#levels(O$LU)
levels(O$LU)<- c('Wetland', 'Forestland', 'Pastureland', "Rangeland",'Cropland')
#create factors for stacked bar plots
O$zero_to_five <- O$SOCstock5
O$five_to_thirty <- O$SOCstock30-O$SOCstock5
O$thirty_to_hundred <- O$SOCstock100- O$SOCstock30
#change orientation
t <- melt(O, id = names(O[,c("rcasiteid", "upedonid", "MO", "LU", "LUGR")]),
measure.vars= names(O[,c("zero_to_five", "five_to_thirty",
"thirty_to_hundred")]))
#change names of variable and value fields
names(t)[6] <- "Depth"
names(t)[7] <- "SOCstock"
t$Depth <- as.factor(t$Depth)
#levels(t$Depth) #check factor levels
#t$Depth <- factor(t$Depth, levels(t$Depth)[c(3,1,2)] # reorder factor levels if needed
levels(t$Depth) = c("0 to 5 cm","5 to 30 cm","30 to 100 cm")
t$Region <- as.factor(t$MO)
#str(t) #check that names and levels are correct
t$SOCstock <- ifelse(is.na(t$SOCstock), 0, t$SOCstock)
#assign a rank value to all pedons within each LU and Region (based on total SOC to 100cm)
P <- t %>%
group_by(MO, LU, rcasiteid) %>%
summarise(Total = sum(SOCstock, na.rm=T)) %>%
arrange(MO, LU, Total) %>%
mutate(rank = dense_rank(Total))
#select pedons for each region and LU (min, max, medoid)
R <- P %>%
group_by (MO, LU) %>%
summarize(Max = max(rank, na.rm=T),
Min = min(rank, na.rm=T),
Med = round(median(rank, na.rm=T),digits=0))%>%
gather(typ, rank, -c(MO,LU))
#Join selections to ranks and then to pedons
Pr <- P %>% right_join(R)
pr <- Pr %>% left_join(t)
#head(pr)
#
#prep levels for plotting
levels(pr$Depth) <- c("0 to 5 cm","5 to 30 cm","30 to 100cm")
pr$Depth <- ordered(pr$Depth, levels =c("30 to 100cm", "5 to 30 cm","0 to 5 cm" ) )
#change variable for clearer labeling
pr$Region <- as.factor(paste0("Region ", pr$MO))
O$LU <- factor(O$LU, levels(O$LU)[c(5,2,3,4,1)])
pr$Type <- as.factor(pr$typ)
levels(pr$Type) = c("Highest", "Medoid", "Lowest" )
ggplot(pr[pr$MO %in% seq(1:4) , ],aes(Type, SOCstock)) +
geom_bar(stat = "identity", aes(fill=Depth)) +
scale_y_reverse() + scale_fill_discrete(guide=guide_legend(reverse=T)) +
facet_grid(Region~LU, scales="free") +
labs(y=expression(paste("SOC stock (Mg ha"^-1,")")),
fill = "Depth Increment")+
theme(legend.position="top",
axis.text.x=element_text(angle=-45, hjust = -.01),
axis.title.x=element_blank())
ggplot(pr[pr$MO %in% seq(5,8,1) , ],aes(Type, SOCstock)) +
geom_bar(stat = "identity", aes(fill=Depth)) +
scale_y_reverse() + scale_fill_discrete(guide=F) +
facet_grid(Region~LU, scales="free") +
labs(y=expression(paste("SOC stock (Mg ha"^-1,")")),
x="Pedon Type", fill = "Depth Increment")+
theme(legend.position="top", axis.text.x=element_text(angle=-45, hjust = -.01))
ggplot(pr[pr$MO %in% seq(9,12,1) , ], aes(Type, SOCstock)) +
geom_bar(stat = "identity", aes(fill=Depth)) +
scale_y_reverse() +
scale_fill_discrete(guide=guide_legend(reverse=T)) +
facet_grid(Region~LU, scales="free") +
labs(y=expression(paste("SOC stock (Mg ha"^-1,")")), fill = "Depth Increment")+
theme(legend.position="top", axis.text.x=element_text(angle=-45, hjust = -.01),
axis.title.x=element_blank(),strip.text.y=element_text(size=6) )
ggplot(pr[pr$MO %in% c(13,14,15,16,18) ,], aes(Type, SOCstock)) +
geom_bar(stat = "identity", aes(fill=Depth)) +
scale_y_reverse() + scale_fill_discrete(guide=F) +
facet_grid(Region~LU, scales="free") +
labs(y=expression(paste("SOC stock (Mg ha"^-1,")")),
x="Pedon Type", fill = "Depth Increment") +
theme(legend.position="top",
axis.text.x=element_text(angle=-45, hjust = -.01),
strip.text.y=element_text(size=6))
rm(O, P, Pr, pr, g)
```
A driving factor in the irregularities between land use - land cover classes and regions are associated with the distributions of organic horizons (denoted as a master horizon 'O'). Nearly all regions have cases with thin organic horizons in forestland. While in some regions, most organic horizons occur in wetlands; in others, there are many organic horizons in cropland and pastureland land uses. This indicates the difficulty in using the hybrid land Use - land Cover classes to aggregate and compare SOC stocks successfully. Wetlands are applied in this study as a land use, but soils that developed under wetlands will still retain some wetland characteristics, like O horizons, after land use has been converted. In region 2, for instance, there are croplands on soils that formed in wetland developed organic soils. These soils have relatively high SOC and bulk density leading to high SOC stocks.
####Fig. S8. Mosaic of contingency values indicating the proportion master horizons occurring in each land use - land cover class, calculated and graphed separately for RaCA Region.
``` {r supp3_hor, eval=T, cache=T}
knitr::opts_chunk$set(echo = T, comment = "#",
message=FALSE, warning = FALSE, fig.width=6, fig.height=6)
library(ggmosaic)
#The disribution of SOC depends more on soil type
# - mineral vs. organic than land use/land cover
#create a mosaic (contingency plot to highlight this)
#limit sample data to major Master horizons and LULC classes with spatial extent
h <- samp[samp$M %in% c("A", "E", "B", "C", "O", "R") & samp$LU != 'X', ]
#set up the factors for plotting
#master horizon
h$M<- droplevels(h$M)
h$M <- factor(h$M, levels = c("O", "A", "E", "B" ,"C", "R"))
#land use/land cover Class
h$LU <- droplevels(h$LU)
h$LU <- factor(h$LU, levels = c('W','F','P', 'R', 'C'))
#levels(h$LU) #check levels
levels(h$LU)<- c('Wetland', 'Forestland', 'Pastureland', "Rangeland",'Cropland')
#region label
h$Region <- factor(paste0("Region ", h$MO))
h$Region <- reorder(h$Region, h$MO, mean)
M1 <- ggplot(data = h[h$MO %in% seq(1:4) ,]) +
geom_mosaic(aes( x = product(M, LU), fill=factor(M)), na.rm=TRUE) +
facet_grid(.~Region) +
scale_fill_brewer(palette="Set1") +
labs(title = '', y ="Master Horizon Proportion",
x="Land Use - Land Cover Proportion") +
theme(legend.position="none",
axis.text.x=element_text(angle=-45, hjust = .1),
axis.title.y = element_text(size = 12),
title = element_text(size = 8),
axis.title.x=element_blank() )
M2 <- ggplot(data = h[h$MO %in% seq(5,8) ,] ) +
geom_mosaic(aes( x = product(M, LU), fill=factor(M)), na.rm=TRUE) + facet_grid(.~Region) +
scale_fill_brewer(palette="Set1") +
labs(y ="Master Horizon Proportion", x="Land Use - Land Cover Class Proportion") +
theme(legend.position="top", legend.title = element_blank(),
axis.text.x=element_text(angle=-45, hjust = .1, size = 8),
axis.text.y = element_text(size = 6),
axis.title.y = element_text(size = 12) )+
guides(fill = guide_legend(nrow = 1))
M3<-ggplot(data = h[h$MO %in% seq(9,12) ,] ) +
geom_mosaic(aes( x = product(M, LU), fill=factor(M)), na.rm=TRUE) + facet_grid(.~Region) +
scale_fill_brewer(palette="Set1") +
labs(title = ' ', y ="Master Horizon Proportion",
x="Land Use - Land Cover Proportion") +
theme(legend.position="none",
axis.text.x=element_text(angle=-45, hjust = .1),
axis.title.x=element_blank(), axis.title.y = element_text(size = 12) )
M4 <- ggplot(data = h[h$MO %in% c(13,14,15,16,18) ,] ) +
geom_mosaic(aes( x = product(M, LU), fill=factor(M)), na.rm=TRUE) +
facet_grid(.~Region) +
scale_fill_brewer(palette="Set1") +
labs(y ="Master Horizon Proportion",
x="Land Use - Land Cover Class Proportion",
fill = "Master Horizon") +
theme(legend.position="top",
axis.text.x=element_text(angle=-45, hjust = .1, size =6),
legend.title = element_blank(),
axis.text.y=element_text(size=8),
axis.title.y = element_text(size = 12)) +
guides(fill = guide_legend(nrow = 1))
M1
M2
M3
M4
```
###Mapping procedures
The RaCA site locations were assigned from GPS latitude and longitude recorded according to the RaCA Field Sampling Protocols [@soilsurveystaffrapid2017]. Polygons were created for RaCA regions by editing the 2008 MO layer (obtained from the National Soil Survey Center) to remove areas not considered part of CONUS. All geographic files were manipulated in the projected coordinate system 'USA_Contiguous_Albers_Equal_Area_Conic_USGS_version' on the NAD North America 1983 Datum.
The basis of the RaCA experimental design and total stock calculations was a combined raster file of the FY12 gSSURGO [@Wickham2009] and 2006 NLCD [@Fry2011] snapped to 30m grid cells. Each grid cell was assigned a combined LUGR label as described above. The LUGR classes were used to aggregate pedon SOC stocks. Pedon stocks were transformed by natural log to better approach normality and then averaged, then the mean value of each LUGR class was back-transformed and this geometric mean assigned and mapped by individual raster cell across CONUS. Standard pyramids were used to smooth visual appearance when zoomed beyond individual raster cells. The pixel count of each LUGR class was used to weight estimates of total CONUS SOC stocks. Total area of each LUGR is equal to the count of each pixel multiplied by the area (or width x height, in this case 30m x 30m) of each pixel.
To display interpolated values between mapped areas, the ordinary kriging function in Geostatistical Analyst __(ArcGIS, ESRI Inc.)__ was used. Pedon SOC to 100cm was log transformed and a constant trend removal was applied to create a prediction surface. An empirical stable semi-variogram with 12 lags of 125m was used to determine kriging weights. The prediction surface captures a fair amount of local variability at CONUS scale but does not over-represent local distributions at the landscape scale. Those estimates were clipped using region boundaries to match the extent of CONUS covered by LUGR classes.
```{r btLUGR, eval=T, warning=F, error=F, cache=T}
library(plyr) #add package back
#combine land use - land cover class and soil group - LUGR
SOCpedons$LUGR <- as.factor(paste0(as.character(SOCpedons$LU),
substr(SOCpedons$rcasiteid,2,5)))
#######################################################################
#CALCULATE LUGR means
#transform each pedon value to better approximate normality