Download NHD

download_nhd(nhd_dir, hu_list, download_files = TRUE)

Arguments

nhd_dir

character directory to save output into

hu_list

character vector of hydrologic region(s) to download. Use get_huc to find HU codes of interest. Accepts two digit and four digit codes.

download_files

boolean if FALSE, only URLs to files will be returned can be hu02s and/or hu04s

Value

character Paths to geodatabases created.

Examples

# \donttest{
hu <- get_huc(sf::st_sfc(sf::st_point(c(-73, 42)), crs = 4326),
                            type = "huc08")
#> Spherical geometry (s2) switched off
#> https://api.water.usgs.gov/geoserver/wmadata/ows 
#> <?xml version="1.0" encoding="UTF-8"?>
#> <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.1.0" outputFormat="application/json" xsi:schemaLocation="http://www.opengis.net/wfs                         http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
#>   <wfs:Query xmlns:feature="https://api.water.usgs.gov/wmadata" typeName="feature:wbd08_20201006" srsName="EPSG:4269">
#>     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
#>       <ogc:And>
#>         <ogc:BBOX>
#>           <ogc:PropertyName>SHAPE</ogc:PropertyName>
#>           <gml:Envelope srsName="urn:x-ogc:def:crs:EPSG:4326">
#>             <gml:lowerCorner>41.9999945892465 -73.0000073573341</gml:lowerCorner>
#>             <gml:upperCorner>42.0000054107534 -72.9999926426652</gml:upperCorner>
#>           </gml:Envelope>
#>         </ogc:BBOX>
#>       </ogc:And>
#>     </ogc:Filter>
#>   </wfs:Query>
#> </wfs:GetFeature>
#> although coordinates are longitude/latitude, st_intersects assumes that they
#> are planar
#> Spherical geometry (s2) switched on

(hu <- substr(hu$huc8, 1, 2))
#> [1] "01"

download_nhd(tempdir(), c(hu, "0203"), download_files = FALSE)
#>  [1] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0101_HU4_GDB.zip"
#>  [2] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0102_HU4_GDB.zip"
#>  [3] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0103_HU4_GDB.zip"
#>  [4] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0104_HU4_GDB.zip"
#>  [5] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0105_HU4_GDB.zip"
#>  [6] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0106_HU4_GDB.zip"
#>  [7] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0107_HU4_GDB.zip"
#>  [8] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0108_HU4_GDB.zip"
#>  [9] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0109_HU4_GDB.zip"
#> [10] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0110_HU4_GDB.zip"
#> [11] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/HU4/GDB/NHD_H_0203_HU4_GDB.zip"
# }