Introduction

This document demonstrates how to use the soilDB package to download data from the Henry Mount soil climate database. Soil climate data are routinely collected by SSO staff via buried sensor/data-logger devices (“hobos”) and now above ground weather stations. The Henry Mount Soil Climate database was established to assist with the management and analysis of these data.

Setup R Environment

With a recent version of R (>= 2.15), it is possible to get all of the packages that this tutorial depends on via:

# run these commands in the R console
install.packages('RColorBrewer', dep=TRUE)
install.packages('reshape', dep=TRUE)
install.packages('dismo', dep=TRUE)
install.packages('rgdal', dep=TRUE)
install.packages('soilDB', dep=TRUE)
# get latest version from GitHub
install.packages('devtools', dep=TRUE)
devtools::install_github("ncss-tech/soilDB", dependencies=FALSE, upgrade_dependencies=FALSE)

Getting and Viewing Data

Soil climate data can be queried by:

and optionally filtered by:

and aggregated to the following granularity: * “hour” (houly data are returned if available) * “day” (MAST and mean summer/winter temperatures are automatically computed) * “week” * “month” * “year”

Query daily sensor data associated with the Sequoia / Kings Canyon soil survey.

library(soilDB)
library(lattice)
library(RColorBrewer)
library(plyr)

# get soil temperature, soil moisture, and air temperature data
x <- fetchHenry(project='CA792')

# check object structure:
str(x, 2)

Quick listing of essential site-level data. “Functional years” is the number of years of non-missing data, after grouping data by Julian day. “Complete years” is the number of years that have 365 days of non-missing data. “dslv” is the number of days since the data-logger was last visited.

# convert into data.frame
d <- as.data.frame(x$sensors)
# keep only information on soil temperature sensors
d <- subset(d, subset=sensor_type == 'soiltemp')
# check top 6 rows and select columns
head(d[, c('user_site_id', 'name', 'sensor_depth', 'MAST', 'Winter', 'Summer', 'STR', 'functional.yrs', 'complete.yrs', 'dslv')])
##    user_site_id       name sensor_depth MAST Winter Summer     STR functional.yrs complete.yrs dslv
## 1 2006CA7920001  Muir Pass           50 1.31  -1.60   5.10  cryic*              7            7  753
## 2 2012CA7921062 Dusy Basin           50 5.47   1.08  12.37 frigid*              1            0 1409
## 3 2015CA7921071    Tyndall           50   NA     NA     NA    <NA>             NA           NA   NA
## 4 S2012CA019001 Littlepete           50 5.48   1.18  10.90 frigid*              2            2  756
## 5 S2012CA019002    LeConte           50 6.79   1.50  12.64 frigid*              2            2  756
## 6 S2012CA019003  McDermand           50 4.02   0.86   8.87 frigid*              2            2  754

Plot Data

Note that there are gaps in the data: between site visits and lack of synchronization of site visits with start/end of the year.

xyplot(sensor_value ~ date_time | name, data=x$soiltemp, main='Daily Soil Temperature (Deg. C)', type=c('l', 'g'), as.table=TRUE, layout=c(2,9), xlab='Date', ylab='Deg C')

xyplot(sensor_value ~ date_time | name, data=x$soilVWC, main='Daily Soil Moisture', type=c('l', 'g'), as.table=TRUE, layout=c(2,6), xlab='Date', ylab='Deg C')

Another approach for investigating data gaps, blue: data, grey: no data.

levelplot(factor(!is.na(sensor_value)) ~ doy * factor(year) | name, main='Daily Soil Temperature (Deg. C)',
data=x$soiltemp, layout=c(2,7), col.regions=c('grey', 'RoyalBlue'), cuts=1, 
colorkey=FALSE, as.table=TRUE, scales=list(alternating=3, cex=0.75), 
par.strip.text=list(cex=0.85), strip=strip.custom(bg='yellow'), 
xlab='Julian Day', ylab='Year')

levelplot(factor(!is.na(sensor_value)) ~ doy * factor(year) | name, main='Daily Soil Moisture',
data=x$soilVWC, layout=c(2,4), col.regions=c('grey', 'RoyalBlue'), cuts=1, 
colorkey=FALSE, as.table=TRUE, scales=list(alternating=3, cex=0.75), 
par.strip.text=list(cex=0.85), strip=strip.custom(bg='yellow'), 
xlab='Julian Day', ylab='Year')

This style of plotting data can be useful for making comparisons between years.

# generate some better colors
cols <- colorRampPalette(rev(brewer.pal(11, 'RdYlBu')), space='Lab', interpolate='spline')

levelplot(sensor_value ~ doy * factor(year) | name, main='Daily Soil Temperature (Deg. C)',
data=x$soiltemp, layout=c(2,7), col.regions=cols,
colorkey=list(space='top'), as.table=TRUE, scales=list(alternating=3, cex=0.75), 
par.strip.text=list(cex=0.85), strip=strip.custom(bg='grey'), 
xlab='Julian Day', ylab='Year')