Skip to content

Commit

Permalink
depriciate get_hydrofabric
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejohnson51 committed May 14, 2024
1 parent 0a6ac9a commit 8a1ac09
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 76 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Imports:
parallel,
pbapply,
rlang,
RSQLite,
rmapshaper,
rvest,
sf,
Expand Down
6 changes: 0 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export(download_fdr_fac)
export(drop_extra_features)
export(flowpaths_to_linestrings)
export(flush_prefix)
export(get_hydrofabric)
export(get_minimal_network)
export(gpkg)
export(hl_to_outlet)
Expand Down Expand Up @@ -99,7 +98,6 @@ importFrom(dplyr,tbl)
importFrom(dplyr,ungroup)
importFrom(dplyr,vars)
importFrom(glue,glue)
importFrom(httr,GET)
importFrom(httr,RETRY)
importFrom(httr,progress)
importFrom(httr,write_disk)
Expand All @@ -113,7 +111,6 @@ importFrom(logger,log_level)
importFrom(methods,as)
importFrom(nhdplusTools,add_plus_network_attributes)
importFrom(nhdplusTools,calculate_total_drainage_area)
importFrom(nhdplusTools,get_boundaries)
importFrom(nhdplusTools,get_node)
importFrom(nhdplusTools,get_sorted)
importFrom(nhdplusTools,get_streamorder)
Expand All @@ -132,9 +129,6 @@ importFrom(rmapshaper,ms_simplify)
importFrom(rvest,html_attr)
importFrom(rvest,html_nodes)
importFrom(rvest,read_html)
importFrom(sbtools,authenticate_sb)
importFrom(sbtools,item_file_download)
importFrom(sbtools,item_list_files)
importFrom(sf,`st_crs<-`)
importFrom(sf,as_Spatial)
importFrom(sf,read_sf)
Expand Down
47 changes: 0 additions & 47 deletions R/hydrofabric_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,53 +140,6 @@ read_hydrofabric = function(gpkg = NULL,

}

#' Download Reference Fabric Data by VPU ID
#' @param VPU a VPU ID
#' @param type either 'refactor' (default) or 'reference'
#' @param dir directory path to save data to
#' @param overwrite should existing files be overwritten? (default = FALSE)
#' @return file path
#' @export
#' @importFrom nhdplusTools get_boundaries
#' @importFrom dplyr filter slice_min
#' @importFrom sbtools item_list_files item_file_download authenticate_sb
#' @importFrom httr GET write_disk progress

get_hydrofabric = function(VPU = "01",
type = "refactor",
dir = NULL,
overwrite = FALSE) {
if (is.null(dir)) {
stop("`dir` cannot be NULL", call. = FALSE)
}

if(!VPU %in% get_boundaries()$VPUID){
stop(VPU, " is not a valid VPU ID", call. = FALSE)
}

outfile = file.path(dir, paste0(type, "_", VPU, ".gpkg"))

if (file.exists(outfile) & !overwrite) {
return(outfile)
} else {

xx = jsonlite::fromJSON(paste0("https://www.sciencebase.gov/catalog/item/",
sb_id(type),
"?format=json"),
simplifyDataFrame = TRUE)

url = filter(xx$files, grepl(VPU, xx$files$name))

unlink(outfile)

sbtools::item_file_download(sb_id(type),
names = url$name,
destinations = outfile,
overwrite_file = overwrite)

return(outfile)
}
}

#' Write a hydrofabric gpkg
#' A hydrofabric consists of a flowpath, catchment,
Expand Down
23 changes: 0 additions & 23 deletions man/get_hydrofabric.Rd

This file was deleted.

0 comments on commit 8a1ac09

Please sign in to comment.