The lab texture (sand, silt, clay fractions) is visualized below on the soil texture triangle. Texture classes as reported in the Soil Veg database are used to color the symbols. Note that there are some cases where mistakes in the lab texture class results in multiple colors per texture class (on the triangle), or in colors from one class "mixing" into other classes (on the triangle).
##
library(plotrix)
library(Rdbi)
library(RdbiPgSQL)
library(Cairo)
##
conn <- dbConnect(PgSQL(), host="localhost", dbname="xxx", user="xxx")
## only select horizons with valid textures
## sand + silt + clay = 100
##
##
query <- dbSendQuery(conn, "SELECT validation_status.pedon_id, a.hz_name, a.hz_top, a.hz_bottom, a.sand, a.silt, a.coarse_clay as clay , (a.sand + a.silt + a.coarse_clay) as ssc, a.lab_texture from validation_status join chemical as a on validation_status.pedon_id = a.pedon_id where validation_status.validated = 't' and a.sand is not NULL and a.silt is not NULL and a.coarse_clay is not NULL and a.hz_top is not NULL and lab_texture is not NULL order by validation_status.pedon_id, a.hz_top asc ;" )
## fetch results
x <- dbGetResult(query)
## only results with valid textures
x <- subset(x, subset=ssc == 100)
## make a list of colors:
cols <- t(col2rgb(as.numeric(factor(x$lab_texture)), alpha=TRUE\))
## plot results to png file:
Cairo(type='png', file='texture_test.png', bg='white', width=600, height=600)
## make triangle
soil.texture(x[,5:7], show.lines=T, show.names=T, col.symbol=rgb(cols[,1], cols[,2], cols[,3], alpha=150, max=255), pch=16, cex=0.75, main=paste("Soil Veg Summary", length(unique(x$pedon_id)), "pedons", length(x$pedon_id), "horizons"))
## close output device
dev.off()
SELECT count(horizon_id) AS horizons_per_day, extract(doy FROM modification_date) AS doy
FROM validation_status JOIN chemical
ON validation_status.pedon_id = chemical.pedon_id
GROUP BY doy
ORDER BY doy;