This document is based on:
Base R (functionality is extended through packages)
Integrated Workflow (self-documenting, repeatable)
Soil Science Specific Packages
Browse some of the various documentation on R
The first time you open RStudio, install required packages:
install.packages('aqp', dep=TRUE)
install.packages("RODBC", dep=TRUE)
install.packages('soilDB', dep=TRUE)
library(aqp)
library(soilDB)
library(latticeExtra)
# ... other libraries you might be using
this is a one-time operation → ODBC setup instructions
getting data from NASIS is as simple as:
# get pedons from the selected set
pedons <- fetchNASIS()
# plot the first 15
plot(pedons[1:15, ])
# get component data from the selected set
components <- get_component_data_from_NASIS_db()
fetchNASIS()
description styles
legacy horizon nomenclature
soils described to varying depths - it's the pits!
Select a set of GHL that best represents a group of pedons to be aggregated.
Assign GHL to each horizon using whatever information is available for grouping horizons.
Evaluate GHL assignments and manually refine as needed.
Keep track of final GHL assignments in NASIS or text file.
Estimate a most likely horizonation e.g., top and bottom depths for each generalized horizon label.
Compute range in characteristics, aka low-rv-high values, for clay, sand, pH, etc. over GHL. (next document in this series)
linked pedons represent examples of the aggregate data, but aggregate data should not be limited to a very small set of linked pedons
IMPORTANT these reports and data summaries are a useful starting point for the aggregation process
soilDB
package for testing purposesA | Bt1 | Bt2 | Bt3 | Oi | R | Cr | Crt | BA | BCt | Bt4 | Bw | CBt | 2BCt | 2Bt3 | 2CB | 2Cr | 2R |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 | 15 | 15 | 10 | 9 | 9 | 8 | 5 | 3 | 3 | 2 | 2 | 2 | 1 | 1 | 1 | 1 | 1 |
2BCt | 2Bt3 | 2CB | 2Cr | 2R | A | BA | BCt | Bt1 | Bt2 | Bt3 | Bt4 | Bw | CBt | Cr | Crt | Oi | R |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | 15 | 3 | 3 | 15 | 15 | 10 | 2 | 2 | 2 | 8 | 5 | 9 | 9 |
pattern matching via regular expression (REGEX)
GHL and rules for our sample dataset:
^A$|Ad|Ap
Bt1$
^Bt2$
^Bt3|^Bt4|CBt$|BCt$|2Bt|2CB$|^C$
Cr
R
special characters in REGEX rules:
|
= “or”^
= anchor to left-side$
= anchor to right-sidenot-used
row2BCt | 2Bt3 | 2CB | 2Cr | 2R | A | BA | BCt | Bt1 | Bt2 | Bt3 | Bt4 | Bw | CBt | Cr | Crt | Oi | R | Sum | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | 0 | 0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 |
Bt1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 |
Bt2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 |
Bt3 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 10 | 2 | 0 | 2 | 0 | 0 | 0 | 0 | 20 |
Cr | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 5 | 0 | 0 | 14 |
R | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 10 |
not-used | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 9 | 0 | 14 |
Sum | 1 | 1 | 1 | 1 | 1 | 15 | 3 | 3 | 15 | 15 | 10 | 2 | 2 | 2 | 8 | 5 | 9 | 9 | 103 |
not-used
group?horizon_agg.txt
, of horizon ID's and corresponding GHL assignmentshorizon_agg.txt file
in: C:/data/horizon_agg.txt
Stephen's Examples:
Dylan's Examples:
Questions, comments, ideas
R resources for pedologists
Additional AQP Contributors: