Henry Mount Soil Climate Database Tutorial

D.E. Beaudette
2017-04-11

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:

  • project (typically a soil survey area, "CA630")
  • NASIS user site ID (e.g. "2006CA7920001")
  • MLRA soil survey office (e.g. "2-SON")

and optionally filtered by:

  • start date ("YYYY-MM-DD")
  • end date ("YYYY-MM-DD")
  • sensor type:
    • "all": all available time series data
    • "soiltemp": soil temperature time series
    • "soilVWC": soil volumetric water content time series
    • "airtemp": air temperature time series
    • "waterlevel": water level time series

and aggregated to the following granularity:

  • "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
2006CA7920001 Muir Pass 50 1.31 -1.60 5.10 cryic* 7 7 625
2012CA7921062 Dusy Basin 50 5.47 1.08 12.37 frigid* 1 0 1281
2015CA7921071 Tyndall 50 NA NA NA NA NA NA NA
S2012CA019001 Littlepete 50 5.48 1.18 10.90 frigid* 2 2 628
S2012CA019002 LeConte 50 6.79 1.50 12.64 frigid* 2 2 628
S2012CA019003 McDermand 50 4.02 0.86 8.87 frigid* 2 2 626

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')

# levelplot(factor(!is.na(sensor_value)) ~ doy * factor(year) | name, main='Daily Air Temperature (Deg. C)',
# data=x$airtemp, layout=c(1,1), 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')