Skip to content

Commit 96af6e0

Browse files
new metadata, better maps
1 parent 13038d1 commit 96af6e0

File tree

2 files changed

+128
-149
lines changed

2 files changed

+128
-149
lines changed

AQP/soilDB/fetchSCAN-demo.Rmd

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,57 @@ library(sharpshootR)
6262
library(reshape2)
6363
library(latticeExtra)
6464
library(tactile)
65-
library(maps)
65+
library(terra)
66+
library(spData)
6667
67-
# get basic sensor metadata for several SCAN/SNOTEL sites
68-
m <- SCAN_site_metadata(site.code=c(2072,356,2148,2187))
68+
# get basic station metadata for several SCAN/SNOTEL sites
69+
m <- SCAN_site_metadata(site.code = c(2072, 356, 2148, 2187))
6970
70-
knitr::kable(m, row.names = FALSE)
71+
# select columns from station metadata
72+
knitr::kable(m[, c('Site', 'Name', 'Network', 'HUC', 'upedonid')], row.names = FALSE)
7173
7274
# result is a list
73-
x <- fetchSCAN(site.code=c(574), year=c(2016))
75+
x <- fetchSCAN(site.code = c(574), year = c(2016))
7476
75-
# print a list of sensor types
76-
names(x[-1])
77+
# print a list of sensor types and associated metadata
78+
names(x)
7779
```
7880

7981

8082
## Metadata for all Stations
8183

82-
```{r, fig.width=8, fig.height=7}
84+
```{r}
8385
data('SCAN_SNOTEL_metadata', package = 'soilDB')
8486
85-
map('state', lwd=2)
86-
title(main='SCAN / SNOTEL Sites')
87-
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=Network == 'SCAN', bg='DarkRed', pch=21)
88-
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=Network == 'SNOTEL', bg='RoyalBlue', pch=21)
87+
# number of stations by network
88+
table(SCAN_SNOTEL_metadata$Network)
89+
```
90+
91+
```{r, fig.width=8, fig.height=7}
92+
data("us_states")
93+
us_states <- vect(us_states)
94+
us_states <- project(us_states, 'epsg:5070')
8995
90-
legend('bottomleft', legend=c('SCAN', 'SNOTEL'), pch=21, pt.bg=c('DarkRed', 'RoyalBlue'), bty='n')
96+
s <- vect(SCAN_SNOTEL_metadata, geom = c('Longitude', 'Latitude'), crs = 'epsg:4269')
97+
s <- project(s, 'epsg:5070')
9198
```
9299

100+
101+
```{r, fig.width=8, fig.height=7}
102+
plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations')
103+
points(s[s$Network %in% c('SCAN', 'CSCAN')], col = 'firebrick')
104+
points(s[s$Network %in% c('SNTL', 'SNTLT')], col = 'royalblue')
105+
106+
legend(x = -2029093, y = 801043.2, legend = c('SCAN / CSCAN', 'SNOTEL / SNOWLITE'), pch = 21, pt.bg = c('firebrick', 'royalblue'), bty = 'n')
107+
```
108+
109+
93110
```{r, fig.width=8, fig.height=7}
94-
map('state', lwd=2)
95-
title(main='SCAN / SNOTEL Sites')
96-
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, bg='RoyalBlue', pch=21, cex=0.85)
97-
points(Latitude ~ Longitude, data=SCAN_SNOTEL_metadata, subset=!is.na(pedlabsampnum), bg='DarkRed', pch=22)
111+
plot(us_states, axes = FALSE, main = 'SCAN, SNOTEL, CSCAN, SNOWLITE Stations')
112+
points(s, col = 'royalblue')
113+
points(s[!is.na(s$pedlabsampnum), ], col = 'firebrick')
98114
99-
legend('bottomleft', legend=c('All Stations', 'Linked to Lab Data'), pch=c(21, 22), pt.bg=c('RoyalBlue', 'DarkRed'), bty='n')
115+
legend(x = -2029093, y = 801043.2, legend = c('All Stations', 'Linked to Lab Data'), pch = 21, pt.bg = c('royalblue', 'firebrick'), bty = 'n')
100116
```
101117

102118

@@ -457,7 +473,7 @@ Get KSSL data for this site, via user pedon ID. This will include estimated para
457473
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).
458474
```{r}
459475
# get KSSL data
460-
s <- fetchKSSL(pedon_id = 'S08NV003003')
476+
s <- fetchLDM(x = 'S08NV003003', what = 'upedonid')
461477
462478
# VG parameters now returned by fetchKSSL() as of 2016-11-17
463479
knitr::kable(horizons(s)[, c('hzn_desgn', 'hzn_top', 'hzn_bot', 'theta_r', 'theta_s', 'alpha', 'npar')])

0 commit comments

Comments
 (0)