Newer
Older

Blodgett, David L.
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
library(sbtools)
library(nhdplusTools)
data_dir <- "data"
hu12_points_path <- file.path(data_dir, "hu_points.gpkg")
if(!file.exists(hu12_points_path)) {
if(is.null(sbtools::current_session()))
sb <- authenticate_sb()
sbtools::item_file_download("5dbc53d4e4b06957974eddae", names = "hu_points.gpkg",
destinations = hu12_points_path, session = sb)
}
gagesiii_points_path <- file.path(data_dir, "GAGESIII_gages")
if(!file.exists(gagesiii_points_path)) {
dir.create(gagesiii_points_path, recursive = TRUE, showWarnings = FALSE)
if(is.null(sbtools::current_session()))
authenticate_sb()
g3z <- "GAGESIII_gages.zip"
sbtools::item_file_download("5dbc53d4e4b06957974eddae", names = g3z,
destinations = file.path(gagesiii_points_path, g3z))
unzip(file.path(gagesiii_points_path, g3z), exdir = gagesiii_points_path)
rm(g3z)
}
nhdplus_dir <- file.path(data_dir, "NHDPlusNationalData")
if(!file.exists(nhdplus_dir)) {
nhdplus_gdb <- download_nhdplusv2(data_dir)
nhdplus_path(nhdplus_gdb)
staged_nhdplus <- stage_national_data()
}