Previously downloaded shapefiles from the USGS
Watershed Boundary Dataset are converted to a
SpatialPolygonsDataFrame with additional columns of data. The resulting file will be
created in the spatial data directory which is set with setSpatialDataDir()
.
convertWBDHUC(dsnPath = NULL, level = 8, extension = "",
nameOnly = FALSE, simplify = FALSE)
directory where the WBD HUC datasets are found
Character or integer which must be 2, 4, 6, 8, 10, 12 or 14.
Character extension associated with mapshaper simplified files.
Logical specifying whether to only return the name without creating the file.
Logical specifying whether to create "_02" and "_01" versions of the file that are simplified to 2% and 1%.
Name of the dataset being created.
The full WBD dataset can be downloaded from the USGS with the following command:
curl https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/WBD/National/GDB/WBD_National_GDB.zip -O
Typically, the raw data will be simplified using mapshaper.
With mapshaper, you can reduce the number of vertices in the polygons, greatly improving the efficiency of spatial searches. Experimentation shows that a reduction to 1-2 of the original shapefile size still retains the recognizable shape of polygons, removing only the higher order "crenellations" in the polygons.
An example use of mapshaper would be:
mapshaper WBDHU2.shp --simplify 1
A full suite of .shp, .shx, .dbf, .prj
files will be created for the new name WBDHU2_02
.
setSpatialDataDir