Skip to content
Snippets Groups Projects
Commit 6110b1b4 authored by Blodgett, David L.'s avatar Blodgett, David L.
Browse files
parent f4255bce
No related branches found
No related tags found
1 merge request!347z cleanup
......@@ -25,6 +25,18 @@ if(!dir.exists("bin")) {dir.create("bin")}
data_dir <- "data"
out_list <- list("data_dir" = data_dir)
out_file <- file.path("cache", "data_paths.json")
sevenz <- "7z"
check_7z <- try(nhdplusTools:::check7z(), silent = TRUE)
if(is(check_7z, "try-error")) {
message("trying to download 7z -- it's not on your path")
# Download command-line Z-zip
if(!file.exists("bin/7za.exe")){
download.file("https://www.7-zip.org/a/7za920.zip", destfile = "bin/7za920.zip")
unzip("bin/7za920.zip", exdir = "bin")
}
sevenz <- "bin/7za.exe"
}
```
```{r HUC12 outlets}
......@@ -88,13 +100,7 @@ if(!file.exists(TE_points_path)) {
sbtools::item_file_download("5dbc53d4e4b06957974eddae", names = TEz,
destinations = file.path(TE_points_path, TEz))
# Download command-line Z-zip
if(!file.exists("bin/7za.exe")){
download.file("https://www.7-zip.org/a/7za920.zip", destfile = "bin/7za920.zip")
unzip("bin/7za920.zip", exdir = "bin")
}
system(paste0("bin/7za.exe e -o", TE_points_path, " ", file.path(TE_points_path, TEz)))
system(paste0(sevenz, " e -o", TE_points_path, " ", file.path(TE_points_path, TEz)))
rm(TEz)
}
......@@ -234,20 +240,20 @@ if(!file.exists(nhdplus_dir)) {
sbtools::item_file_download("5dbc53d4e4b06957974eddae", names = gLz,
destinations = file.path(nhdplus_dir, gLz))
system(paste0("7z e -o", nhdplus_dir, " ", file.path(nhdplus_dir, gLz)))
system(paste0(sevenz, " e -o", nhdplus_dir, " ", file.path(nhdplus_dir, gLz)))
xWalk <- "CrosswalkTable_NHDplus_HU12_CSV.7z"
sbtools::item_file_download("5c86a747e4b09388244b3da1", names = xWalk,
destinations = file.path(nhdplus_dir, xWalk))
system(paste0("7z e -o", nhdplus_dir, " ", file.path(nhdplus_dir, xWalk)))
system(paste0(sevenz, nhdplus_dir, " ", file.path(nhdplus_dir, xWalk)))
x <- tryCatch(
download_nhdplusv2(data_dir),
# Quiet the download, overwrite existing files
error = function(e)
{system(paste0("7z x ", file.path(data_dir, "NHDPlusV21_NationalData_Seamless_Geodatabase_Lower48_07.7z")
{system(paste0(sevenz, " x ", file.path(data_dir, "NHDPlusV21_NationalData_Seamless_Geodatabase_Lower48_07.7z")
, " -o", data_dir), ignore.stdout = T)}
)
......
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