diff --git a/AQP/soilDB/fetchSCAN-demo.Rmd b/AQP/soilDB/fetchSCAN-demo.Rmd index af41c03..89c9c18 100644 --- a/AQP/soilDB/fetchSCAN-demo.Rmd +++ b/AQP/soilDB/fetchSCAN-demo.Rmd @@ -62,41 +62,57 @@ library(sharpshootR) library(reshape2) library(latticeExtra) library(tactile) -library(maps) +library(terra) +library(spData) -# get basic sensor metadata for several SCAN/SNOTEL sites -m <- SCAN_site_metadata(site.code=c(2072,356,2148,2187)) +# get basic station metadata for several SCAN/SNOTEL sites +m <- SCAN_site_metadata(site.code = c(2072, 356, 2148, 2187)) -knitr::kable(m, row.names = FALSE) +# select columns from station metadata +knitr::kable(m[, c('Site', 'Name', 'Network', 'HUC', 'upedonid')], row.names = FALSE) # result is a list -x <- fetchSCAN(site.code=c(574), year=c(2016)) +x <- fetchSCAN(site.code = c(574), year = c(2016)) -# print a list of sensor types -names(x[-1]) +# print a list of sensor types and associated metadata +names(x) ``` ## Metadata for all Stations -```{r, fig.width=8, fig.height=7} +```{r} 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) +# number of stations by network +table(SCAN_SNOTEL_metadata$Network) +``` + +```{r, fig.width=8, fig.height=7} +data("us_states") +us_states <- vect(us_states) +us_states <- project(us_states, 'epsg:5070') -legend('bottomleft', legend=c('SCAN', 'SNOTEL'), pch=21, pt.bg=c('DarkRed', 'RoyalBlue'), bty='n') +s <- vect(SCAN_SNOTEL_metadata, geom = c('Longitude', 'Latitude'), crs = 'epsg:4269') +s <- project(s, 'epsg:5070') ``` + +```{r, fig.width=8, fig.height=7} +plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations') +points(s[s$Network %in% c('SCAN', 'CSCAN')], col = 'firebrick') +points(s[s$Network %in% c('SNTL', 'SNTLT')], col = 'royalblue') + +legend(x = -2029093, y = 801043.2, legend = c('SCAN / CSCAN', 'SNOTEL / SNOWLITE'), pch = 21, pt.bg = c('firebrick', 'royalblue'), bty = 'n') +``` + + ```{r, fig.width=8, fig.height=7} -map('state', lwd=2) -title(main='SCAN / SNOTEL Sites') -points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, bg='RoyalBlue', pch=21, cex=0.85) -points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=!is.na(pedlabsampnum), bg='DarkRed', pch=22) +plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations') +points(s, col = 'royalblue') +points(s[!is.na(s$pedlabsampnum), ], col = 'firebrick') -legend('bottomleft', legend=c('All Stations', 'Linked to Lab Data'), pch=c(21, 22), pt.bg=c('RoyalBlue', 'DarkRed'), bty='n') +legend(x = -2029093, y = 801043.2, legend = c('All Stations', 'Linked to Lab Data'), pch = 21, pt.bg = c('royalblue', 'firebrick'), bty = 'n') ``` @@ -457,7 +473,7 @@ Get KSSL data for this site, via user pedon ID. This will include estimated para Previously the VG parameters had to be obtained manually from [these reports](https://ncsslabdatamart.sc.egov.usda.gov/rptExecute.aspx?p=34942&r=6&submit1=Get+Report). ```{r} # get KSSL data -s <- fetchKSSL(pedon_id = 'S08NV003003') +s <- fetchLDM(x = 'S08NV003003', what = 'upedonid') # VG parameters now returned by fetchKSSL() as of 2016-11-17 knitr::kable(horizons(s)[, c('hzn_desgn', 'hzn_top', 'hzn_bot', 'theta_r', 'theta_s', 'alpha', 'npar')]) diff --git a/AQP/soilDB/fetchSCAN-demo.html b/AQP/soilDB/fetchSCAN-demo.html index ac8737e..64a9b01 100644 --- a/AQP/soilDB/fetchSCAN-demo.html +++ b/AQP/soilDB/fetchSCAN-demo.html @@ -11,7 +11,7 @@ - +
Site | 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 | -13N97485 | -|
2072 | Eros Data Center | -2072 | -South Dakota | SCAN | -Minnehaha | -1602 | -43.73835 | --96.61455 | 101702031402 | -Eros Data Center | S2003SD099001 | -03N0688 |
356 | +Blue Lakes | +SNTL | +180400120101 | +NA | +||||||||
2148 | Jordan Valley Cwma | -2148 | -Idaho | SCAN | -Owyhee | -4508 | -42.94863 | --117.01060 | 170501080405 | NA | -NA | -NA | +
2187 | +Deep Springs | +SCAN | +180902010102 | +S2012CA027002 |
# result is a list
-x <- fetchSCAN(site.code=c(574), year=c(2016))
+x <- fetchSCAN(site.code = c(574), year = c(2016))
-# print a list of sensor types
-names(x[-1])
-## [1] "STO" "SAL" "TAVG" "TMIN" "TMAX" "PRCP" "PREC" "SNWD"
-## [9] "WTEQ" "WDIRV" "WSPDV" "LRADT" "metadata"
+# print a list of sensor types and associated metadata
+names(x)
+## [1] "SMS" "STO" "SAL" "TAVG" "TMIN" "TMAX" "PRCP" "PREC"
+## [9] "SNWD" "WTEQ" "WDIRV" "WSPDV" "LRADT" "metadata"
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')
-
-map('state', lwd=2)
-title(main='SCAN / SNOTEL Sites')
-points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, bg='RoyalBlue', pch=21, cex=0.85)
-points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=!is.na(pedlabsampnum), bg='DarkRed', pch=22)
-
-legend('bottomleft', legend=c('All Stations', 'Linked to Lab Data'), pch=c(21, 22), pt.bg=c('RoyalBlue', 'DarkRed'), bty='n')
-
+# number of stations by network
+table(SCAN_SNOTEL_metadata$Network)
+##
+## CSCAN SCAN SNTL SNTLT
+## 21 210 910 45
+data("us_states")
+us_states <- vect(us_states)
+us_states <- project(us_states, 'epsg:5070')
+
+s <- vect(SCAN_SNOTEL_metadata, geom = c('Longitude', 'Latitude'), crs = 'epsg:4269')
+s <- project(s, 'epsg:5070')
+plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations')
+points(s[s$Network %in% c('SCAN', 'CSCAN')], col = 'firebrick')
+points(s[s$Network %in% c('SNTL', 'SNTLT')], col = 'royalblue')
+
+legend(x = -2029093, y = 801043.2, legend = c('SCAN / CSCAN', 'SNOTEL / SNOWLITE'), pch = 21, pt.bg = c('firebrick', 'royalblue'), bty = 'n')
+
+plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations')
+points(s, col = 'royalblue')
+points(s[!is.na(s$pedlabsampnum), ], col = 'firebrick')
+
+legend(x = -2029093, y = 801043.2, legend = c('All Stations', 'Linked to Lab Data'), pch = 21, pt.bg = c('royalblue', 'firebrick'), bty = 'n')
+
## List of 14
-## $ SMS :'data.frame': 6656 obs. of 8 variables:
-## $ STO :'data.frame': 7296 obs. of 8 variables:
+## $ SMS :'data.frame': 6656 obs. of 9 variables:
+## $ STO :'data.frame': 7296 obs. of 9 variables:
## $ SAL :'data.frame': 0 obs. of 0 variables
-## $ TAVG :'data.frame': 1459 obs. of 8 variables:
-## $ TMIN :'data.frame': 1459 obs. of 8 variables:
-## $ TMAX :'data.frame': 1459 obs. of 8 variables:
-## $ PRCP :'data.frame': 1319 obs. of 8 variables:
-## $ PREC :'data.frame': 1323 obs. of 8 variables:
+## $ TAVG :'data.frame': 1459 obs. of 9 variables:
+## $ TMIN :'data.frame': 1459 obs. of 9 variables:
+## $ TMAX :'data.frame': 1459 obs. of 9 variables:
+## $ PRCP :'data.frame': 1319 obs. of 9 variables:
+## $ PREC :'data.frame': 1323 obs. of 9 variables:
## $ SNWD :'data.frame': 0 obs. of 0 variables
## $ WTEQ :'data.frame': 0 obs. of 0 variables
## $ WDIRV :'data.frame': 0 obs. of 0 variables
## $ WSPDV :'data.frame': 0 obs. of 0 variables
## $ LRADT :'data.frame': 0 obs. of 0 variables
-## $ metadata:'data.frame': 1 obs. of 12 variables:
+## $ metadata:'data.frame': 1 obs. of 19 variables:
# tabulate number of soil moisture measurements per depth (cm)
table(x$SMS$depth)
##
@@ -627,23 +589,23 @@ Getting Data from Multiple Stations
# same format as before, sensor data are "stacked" within each list element
str(x, 1)
## List of 14
-## $ SMS :'data.frame': 5752 obs. of 8 variables:
-## $ STO :'data.frame': 5843 obs. of 8 variables:
+## $ SMS :'data.frame': 5752 obs. of 9 variables:
+## $ STO :'data.frame': 5843 obs. of 9 variables:
## $ SAL :'data.frame': 0 obs. of 0 variables
-## $ TAVG :'data.frame': 1460 obs. of 8 variables:
-## $ TMIN :'data.frame': 1460 obs. of 8 variables:
-## $ TMAX :'data.frame': 1460 obs. of 8 variables:
-## $ PRCP :'data.frame': 581 obs. of 8 variables:
-## $ PREC :'data.frame': 1316 obs. of 8 variables:
-## $ SNWD :'data.frame': 731 obs. of 8 variables:
-## $ WTEQ :'data.frame': 713 obs. of 8 variables:
+## $ TAVG :'data.frame': 1460 obs. of 9 variables:
+## $ TMIN :'data.frame': 1460 obs. of 9 variables:
+## $ TMAX :'data.frame': 1460 obs. of 9 variables:
+## $ PRCP :'data.frame': 581 obs. of 9 variables:
+## $ PREC :'data.frame': 1316 obs. of 9 variables:
+## $ SNWD :'data.frame': 731 obs. of 9 variables:
+## $ WTEQ :'data.frame': 713 obs. of 9 variables:
## $ WDIRV :'data.frame': 0 obs. of 0 variables
## $ WSPDV :'data.frame': 0 obs. of 0 variables
## $ LRADT :'data.frame': 0 obs. of 0 variables
-## $ metadata:'data.frame': 2 obs. of 12 variables:
+## $ metadata:'data.frame': 2 obs. of 19 variables:
# deeper look
str(x$SMS)
-## 'data.frame': 5752 obs. of 8 variables:
+## 'data.frame': 5752 obs. of 9 variables:
## $ Site : int 356 356 356 356 356 356 356 356 356 356 ...
## $ Date : Date, format: "2015-01-01" "2015-01-02" "2015-01-03" ...
## $ Time : chr "12:00" "12:00" "12:00" "12:00" ...
@@ -651,7 +613,8 @@ Getting Data from Multiple Stations
## $ water_day : int 93 94 95 96 97 98 99 100 101 102 ...
## $ value : num 0 0 0 0 0 0 0 0 0 0 ...
## $ depth : num 5 5 5 5 5 5 5 5 5 5 ...
-## $ sensor.id : Factor w/ 5 levels "SMS.I_2","SMS.I_8",..: 1 1 1 1 1 1 1 1 1 1 ...
+## $ sensor.id : Factor w/ 5 levels "SMS.I_2","SMS.I_8",..: 1 1 1 1 1 1 1 1 1 1 ...
+## $ datetime : POSIXct, format: "2015-01-01 12:00:00" "2015-01-02 12:00:00" "2015-01-03 12:00:00" ...
# get unique set of soil moisture sensor depths
sensor.depths <- unique(x$SMS$depth)
@@ -863,20 +826,20 @@ Case Study: Pine Nut SCAN Site
# check available data
str(x, 1)
## List of 14
-## $ SMS :'data.frame': 14259 obs. of 8 variables:
-## $ STO :'data.frame': 27933 obs. of 8 variables:
+## $ SMS :'data.frame': 14259 obs. of 9 variables:
+## $ STO :'data.frame': 27933 obs. of 9 variables:
## $ SAL :'data.frame': 0 obs. of 0 variables
-## $ TAVG :'data.frame': 2918 obs. of 8 variables:
-## $ TMIN :'data.frame': 2917 obs. of 8 variables:
-## $ TMAX :'data.frame': 2919 obs. of 8 variables:
-## $ PRCP :'data.frame': 2918 obs. of 8 variables:
-## $ PREC :'data.frame': 2927 obs. of 8 variables:
-## $ SNWD :'data.frame': 1407 obs. of 8 variables:
+## $ TAVG :'data.frame': 2918 obs. of 9 variables:
+## $ TMIN :'data.frame': 2917 obs. of 9 variables:
+## $ TMAX :'data.frame': 2919 obs. of 9 variables:
+## $ PRCP :'data.frame': 2918 obs. of 9 variables:
+## $ PREC :'data.frame': 2927 obs. of 9 variables:
+## $ SNWD :'data.frame': 1407 obs. of 9 variables:
## $ WTEQ :'data.frame': 0 obs. of 0 variables
## $ WDIRV :'data.frame': 0 obs. of 0 variables
## $ WSPDV :'data.frame': 0 obs. of 0 variables
## $ LRADT :'data.frame': 0 obs. of 0 variables
-## $ metadata:'data.frame': 1 obs. of 12 variables:
+## $ metadata:'data.frame': 1 obs. of 19 variables:
## still working on a solution for this issue: https://github.com/ncss-tech/soilDB/issues/14
# ! multiple soil temperature sensors installed at each depth
table(sensor.id = x$STO$sensor.id, sensor.depth = x$STO$depth)
@@ -904,13 +867,13 @@ ## Site Date Time water_year water_day value depth sensor.id year doy
-## 1 2144 2008-01-01 12:00 2008 93 2.1 5 SMS.I_2 2008 1
-## 2 2144 2008-01-02 12:00 2008 94 1.8 5 SMS.I_2 2008 2
-## 3 2144 2008-01-03 12:00 2008 95 2.6 5 SMS.I_2 2008 3
-## 4 2144 2008-01-04 12:00 2008 96 3.3 5 SMS.I_2 2008 4
-## 5 2144 2008-01-05 12:00 2008 97 5.1 5 SMS.I_2 2008 5
-## 6 2144 2008-01-06 12:00 2008 98 12.1 5 SMS.I_2 2008 6
+## Site Date Time water_year water_day value depth sensor.id datetime year doy
+## 1 2144 2008-01-01 12:00 2008 93 2.1 5 SMS.I_2 2008-01-01 12:00:00 2008 1
+## 2 2144 2008-01-02 12:00 2008 94 1.8 5 SMS.I_2 2008-01-02 12:00:00 2008 2
+## 3 2144 2008-01-03 12:00 2008 95 2.6 5 SMS.I_2 2008-01-03 12:00:00 2008 3
+## 4 2144 2008-01-04 12:00 2008 96 3.3 5 SMS.I_2 2008-01-04 12:00:00 2008 4
+## 5 2144 2008-01-05 12:00 2008 97 5.1 5 SMS.I_2 2008-01-05 12:00:00 2008 5
+## 6 2144 2008-01-06 12:00 2008 98 12.1 5 SMS.I_2 2008-01-06 12:00:00 2008 6
head(sms.wide)
## Site Date 5 10 20 51 102
## 1 2144 2008-01-01 2.1 4.4 8.8 9.2 2.0
@@ -968,7 +931,7 @@ Water Retention Curve Development
Previously the VG parameters had to be obtained manually from these
reports.
# get KSSL data
-s <- fetchKSSL(pedon_id = 'S08NV003003')
+s <- fetchLDM(x = 'S08NV003003', what = 'upedonid')
# VG parameters now returned by fetchKSSL() as of 2016-11-17
knitr::kable(horizons(s)[, c('hzn_desgn', 'hzn_top', 'hzn_bot', 'theta_r', 'theta_s', 'alpha', 'npar')])
@@ -1245,8 +1208,8 @@ Conversion of VWC to Matric Potential: All Depths
xlab='Julian Day', ylab='Year')
This document is based on aqp
version 2.0.2 and
-soilDB
version 2.7.8.
This document is based on aqp
version 2.0.4 and
+soilDB
version 2.8.5.