Skip to content
Snippets Groups Projects
Commit 5bc594ed authored by Santiago, Marilyn's avatar Santiago, Marilyn :cat:
Browse files

reservoir data download added

parent f83939fb
No related branches found
No related tags found
1 merge request!122reservoir downloads and gage DAs
......@@ -626,6 +626,77 @@ if(!file.exists(out$new_nhdp_rds)) {
out_list <- c(out_list, out)
```
```{r res}
# Download Reservoir and dams data: ResOps, ISTARF and GRanDd
#
# reservoir operations reference
# https://www.sciencedirect.com/science/article/pii/S0022169421008933
#
# Set Data download links
res_att_url <- "https://zenodo.org/record/5367383/files/ResOpsUS.zip?download=1"
# ISTARF - Inferred Storage Targets and Release Functions for CONUS large reservoirs
istarf_url <- "https://zenodo.org/record/4602277/files/ISTARF-CONUS.csv?download=1"
# GRAND
grand_url <- "https://m201.syncusercontent1.com/mfs-60:cb764c38e10689d37f067dc827055b4b=============================/p/GRanD_Version_1_3.zip?allowdd=0&datakey=OoaG+GeAwKv7TFveuZwDVnSXRcvaZG+XvvklU+/4tr6aP3XQQ9IUW7qMMEYmApu5HJvQHgW64y3O3bFV835K9BRs+Nglfk/S0vI4OM74jcbTKVkEnBq/lVLo64YMurDs1JwNE9wmXLZoUEYnvX6it1dl9OnHY+xgmdDJejUBET26547cXRzDnxNUhAt7WJph53cWTIqIuuHAUwwAdo1l3xpEnWAJ60urUePlkUgGrwuCFRypjvFTGbsopry5UM9hNmYW1w0rf9g2ISZ6wDeEKUd4EaftRqR8L/H4lyz2Q1Nkvr0W00D0HQUEAoAVYNe2YwJWUUOJr7ScHl3a87f73w&engine=ln-1.11.16&errurl=ZrN5INDSHLltXskcleZ7HsQsWC1kztNk+X7QQTq4WmbGVrLdje+FmaDw+yhiCT/UhHt+2PcW8skN2COFWDDo+92lr3g6zvA4WMP76H5fCQ14Hft9yOILIw63tUI4LTgkq6Ur54yZUAW3ndfxpPt9334Awd59xZm9Y16RayiILVqUaJ6i1tccS/mMObqW5Cxa6z9+FNp5iujkHjha+7ABSDOtYcdlgjlKsbpHexICh/GxKNb2Dufg71oi4tVtWiPlhjUwbR9cB9Zi3ifqc/xv5KBmcybo09TpBrROTk64uFgrmkyFKNlb2pGvTx/G8jkNqbaPd+oX7BkKewhUw0b6iQ==&header1=Q29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi96aXA&header2=Q29udGVudC1EaXNwb3NpdGlvbjogYXR0YWNobWVudDsgZmlsZW5hbWU9IkdSYW5EX1ZlcnNpb25fMV8zLnppcCI7ZmlsZW5hbWUqPVVURi04JydHUmFuRF9WZXJzaW9uXzFfMy56aXA7&ipaddress=1799926369&linkcachekey=bd47eb6b0&linkoid=51000013&mode=101&sharelink_id=447819520013&timestamp=1647284919416&uagent=6f3d88e3287d3ce590637b5b065b0a4b93d1b38a&signature=e4682db0fbf848c522a63cb9829f07e48e131dc3&cachekey=60:cb764c38e10689d37f067dc827055b4b============================="
#
# # - ResOpsUS - reservoir operations
res_path <- file.path(data_dir,"reservoir_Data")
if(!dir.exists(res_path))
dir.create(res_path, recursive = TRUE)
the_ex_dir <- file.path(res_path,"ResOpsUS")
tab_out <- list(res_attributes = file.path(the_ex_dir, "attributes","reservoir_attributes.csv"))
# Download ResOpsUS data
zip <- file.path(res_path, "ResOpsUS.zip")
if(!file.exists(zip)) {
# set mode wb for a file of type zip
download.file(res_att_url, destfile = zip, mode = "wb")
unzip(zip,exdir = the_ex_dir)
}
out_list <- c(out_list, tab_out)
#
# Download istarf data
istarf_csv <- file.path(res_path, "ISTARF-CONUS.csv")
if(!file.exists(istarf_csv)) {
download.file(istarf_url, destfile = istarf_csv, mode = "w")
}
tab_out <- list(istarf = istarf_csv)
out_list <- c(out_list, tab_out)
#
# crosswalk of selected (fit %in% c("full", "storage_only") 595 ResOpsUS to NID
# - derived by msant and abock; currently hosted at GFv2 POI Source data page
resops_to_nid_path <- file.path(res_path, "cw_ResOpsUS_NID.csv")
if(!file.exists(resops_to_nid_path)) {
if(is.null(sbtools::current_session()))
sb <- authenticate_sb()
sbtools::item_file_download("5dbc53d4e4b06957974eddae", names = "cw_ResOpsUS_NID.csv",
destinations = resops_to_nid_path, session = sb)
}
tab_out <- list(resops_NID_CW = resops_to_nid_path)
out_list <- c(out_list, tab_out)
#
# Download GRanD_Version_1_3
the_ex_dir <- file.path(res_path,"GRanD_Version_1_3")
g13_out <- list(grandv13_lyr = file.path(the_ex_dir, "GRanD_dams_v1_3.shp"))
zip <- file.path(res_path, "GRanD_Version_1_3.zip")
if(!file.exists(zip)) {
# set mode wb for a file of type zip
download.file(grand_url, destfile = zip, mode = "wb")
unzip(zip,exdir = res_path)
}
out_list <- c(out_list,g13_out)
```
```{r}
write_json(out_list, path = out_file, pretty = TRUE, auto_unbox = TRUE)
rm(out_list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment