Introduction

This document demonstrates how to use the soilDB package to download climate data from the SCAN/SNOTEL network. Stay tuned for updates and more detailed examples.

Note

This interface is very much a work in progress. There are some SCAN / SNOTEL site with multiple (above-ground) sensors per sensor prefix, which can lead to confusing results. For now the first above-ground sensor is selected for each above-ground sensor prefix: c('TAVG', 'PRCP', 'PREC', 'SNWD', 'WTEQ', 'WDIRV', 'WSPDV', 'LRADT').

There are some sites with multiple below-ground sensors installed at the same depth. A message is printed when this happens. You can use the sensor.id column to access specific sensors. We are working on a solution.

Installation

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('latticeExtra', dep=TRUE)
install.packages('plyr', dep=TRUE)
install.packages('rvest', dep=TRUE)
install.packages('httr', dep=TRUE)
install.packages('reshape2', dep=TRUE)
install.packages('soilDB', dep=TRUE)

You will also need the latest version of soilDB and aqp:

install.packages('devtools', dep=TRUE)
devtools::install_github("ncss-tech/aqp", dependencies=FALSE, upgrade_dependencies=FALSE)
devtools::install_github("ncss-tech/soilDB", dependencies=FALSE, upgrade_dependencies=FALSE)

Sensor Metadata

Metadata for Select Stations

Each SCAN / SNOTEL station may have a different set of sensors.

# load required packages
library(aqp)
library(soilDB)
library(reshape2)
library(plyr)
library(latticeExtra)
library(maps)

# get basic sensor metadata for several SCAN/SNOTEL sites
m <- SCAN_site_metadata(site.code=c(2072,356,2148,2187))

knitr::kable(m, row.names = FALSE)
Name Site State Network County Elevation_ft Latitude Longitude HUC climstanm upedonid pedlabsampnum
Blue Lakes 356 California SNOTEL Alpine 8067 38.60800 -119.92437 180400120101 NA NA NA
Deep Springs 2187 California SCAN Inyo 5399 37.37222 -117.97383 180902010102 Deep Springs S2012CA027002
Eros Data Center 2072 South Dakota SCAN Minnehaha 1602 43.73835 -96.61455 101702031402 Eros Data Center S2003SD099001 03N0688
Jordan Valley Cwma 2148 Idaho SCAN Owyhee 4508 42.94863 -117.01060 170501080405 NA NA NA
x <- fetchSCAN(site.code=c(574), year=c(2016))

# print a list of sensor types
names(x[-1])
##  [1] "SMS"   "STO"   "SAL"   "TAVG"  "TMIN"  "TMAX"  "PRCP"  "PREC"  "SNWD"  "WTEQ"  "WDIRV" "WSPDV"
## [13] "LRADT"

Metadata for all Stations

data('SCAN_SNOTEL_metadata', package = 'soilDB')

map('state', lwd=2)
title(main='SCAN / SNOTEL Sites')
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=Network == 'SCAN', bg='DarkRed', pch=21)
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=Network == 'SNOTEL', bg='RoyalBlue', pch=21)

legend('bottomleft', legend=c('SCAN', 'SNOTEL'), pch=21, pt.bg=c('DarkRed', 'RoyalBlue'), bty='n')