Download a national NHDPlus Version 2.1 .7z archive from Amazon S3.
The selected region and data type determine the archive to download.
Arguments
- region
character(1). Archive region:
"Lower48"(default) or"Islands".- type
character(1). Data type:
"Seamless"(default) or"OceanCatchment".- directory_to_save
character(1). Non-empty parent directory. The
.7zarchive is saved inzip_files/; whenunzip = TRUE, its contents are extracted intodata_files/.- acknowledgement
logical(1). Must be
TRUEto proceed. Downloaded archives and extracted data can require substantial storage.- download
logical(1). Deprecated.
FALSEemits a warning and returns a preview of the planned archive without downloading or extracting it. Default isTRUE.- remove_command
logical(1). Deprecated and ignored;
TRUEemits a warning. No command file is generated. Default isFALSE.- unzip
logical(1). Extract the downloaded
.7zarchive intodata_files/using the archive package. Default isFALSE, which retains the archive without extracting its contents.- remove_zip
logical(1). Remove the downloaded
.7zarchive and itszip_files/directory, including remaining contents, after extraction. Default isFALSE. May beTRUEonly whenunzip = TRUE.- hash
logical(1). Return a combined MD5 hash of the files under
data_files/instead of the download summary whendownload = TRUE. Ignored whendownload = FALSE. Default isFALSE.- show_progress
logical(1). Show per-file messages and download progress bars during sequential downloads. Default is
TRUE. Ignored during concurrent downloads, where per-file progress is disabled. Status and summary messages may still be printed whenFALSE.- max_tries
integer(1). Maximum attempts per file download request, including the initial attempt. Default is 20.
- rate_limit
numeric(1). Request-throttling interval in seconds. Default is 2. Passed unchanged to
download_run_method()for sequential downloads. For concurrent downloads, multiplied by the configured daemon count for the"default"compute profile before being passed to each worker.
Value
When download = FALSE, an invisible list containing urls, destfiles,
and n_files = 1 is returned regardless of hash.
When download = TRUE and hash = FALSE, returns the download summary from
download_run() invisibly, including success, failed, and
skipped file counts. The summary always contains failed_urls and
failed_files character vectors, both character(0) when no downloads
failed, including when every file was skipped. Counts describe archive
downloads, not extracted files.
When download = TRUE and hash = TRUE, returns a visible character scalar
containing the combined MD5 hash of the files under data_files/.
Details
region and type each select one value. Matching is case-sensitive, and
unambiguous abbreviations are accepted. If omitted, each argument uses its
first listed choice.
zip_files/ and data_files/ are sibling directories created beneath
directory_to_save, including when unzip = FALSE or download = FALSE.
Preview mode returns the planned archive even if it already exists locally
and does not check remote availability.
During downloading, download_run() skips an existing non-empty
archive in zip_files/. That archive is still passed to extraction when
unzip = TRUE. Existing extracted data alone do not cause a download to
be skipped. Archive member names and paths are preserved beneath
data_files/; pass the extracted geodatabase path to process_huc().
Hashing includes all files recursively under data_files/, including
existing files, and excludes archives in zip_files/. With unzip = FALSE,
hashing still uses data_files/, which may be empty or contain previously
extracted data.
Note
For HUC, set type = "Seamless". HUC12 layer presents in the seamless
geodatabase. Users can aggregate HUC12 layer to make HUC6, HUC8, HUC10, etc.
For whom wants to download a specific region,
please visit Get NHDPlus Data
Concurrent downloads
File downloads use configured daemons in the "default" compute profile,
or run sequentially when that profile has no configured daemons.
Daemon creation and shutdown are managed by the caller using
mirai::daemons(). For concurrent downloads, configure a fixed local pool
with mirai::daemons(n, .compute = "default") before calling this function.
Daemon detection, counting, and task dispatch always use the "default"
compute profile, regardless of the active profile. Daemon counting and rate
scaling assume that the pool still contains the n workers configured by
that call, with no workers added separately or pool resizing during
downloads. Each worker receives one URL/destination pair per task; the
remaining request arguments are constant across tasks.
Source-specific validation, URL discovery, archive extraction, and directory hashing run in the calling process. Only file downloads are dispatched to workers.
References
U.S. Geological Survey (2023). “National Hydrography Dataset (NHD) – USGS National Map Downloadable Data Collection.” https://www.usgs.gov/national-hydrography.