-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mostly for my own curiosity, but we will have to address eventually
- Loading branch information
1 parent
6517954
commit 2af12a4
Showing
1 changed file
with
24 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
library(soilDB) | ||
library(lattice) | ||
library(latticeExtra) | ||
library(tactile) | ||
|
||
x <- SDA_query("SELECT soiltaxedition, SUM((comppct_r / 100) * muacres) AS ac from mapunit JOIN component on mapunit.mukey = component.mukey WHERE soiltaxedition IS NOT NULL GROUP BY soiltaxedition ORDER BY ac DESC;") | ||
# let SDA do the work | ||
# approx. MU acres by ST edition | ||
x <- SDA_query("SELECT | ||
soiltaxedition, SUM((comppct_r / 100) * muacres) AS ac | ||
FROM mapunit AS mu | ||
JOIN component AS co ON mu.mukey = co.mukey | ||
WHERE soiltaxedition IS NOT NULL | ||
GROUP BY soiltaxedition | ||
ORDER BY ac DESC;") | ||
|
||
|
||
# remove 'edition' for simpler axes labels | ||
x$ed <- gsub(pattern = ' edition', replacement = '', x$soiltaxedition) | ||
|
||
# numerical ordering | ||
x$ed <- factor(x$ed, levels = c('first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'thirteenth')) | ||
|
||
# sort by acreage | ||
x$ed.sorted <- factor(x$ed, levels = x$ed[order(x$ac)]) | ||
|
||
|
||
p1 <- dotplot(ed ~ ac / 1e6, data = x, par.settings = tactile.theme(), xlab = 'Millions of Acres (SSURGO)', ylab = 'ST Edition') | ||
# unsorted | ||
p1 <- dotplot(ed ~ ac / 1e6, data = x, par.settings = tactile.theme(), xlab = 'Millions of Acres', ylab = 'ST Edition', type = c('p', 'g')) | ||
|
||
# sorted | ||
p2 <- dotplot(ed.sorted ~ ac / 1e6, data = x, par.settings = tactile.theme(), xlab = 'Millions of Acres', ylab = 'ST Edition', type = c('p', 'g')) | ||
|
||
# combine figures | ||
p <- c(p1, p2, x.same = TRUE) | ||
|
||
p2 <- dotplot(ed.sorted ~ ac / 1e6, data = x, par.settings = tactile.theme(), xlab = 'Millions of Acres (SSURGO)', ylab = 'ST Edition') | ||
# add scales to both panels | ||
p <- update(p, scales = list(alternating = 3), main = 'Editions of KST\nFY23 SSURGO') | ||
|
||
p <- c(p1, p2) | ||
# neat | ||
print(p) | ||
|
||
p <- update(p, scales = list(alternating = 3)) | ||
|
||
p |