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 extsion 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 the command line version of mapshpaper. (Installation instructions are found at this URL.)
With mapshaper, you can reduce the number of vertices in the polygons, greatly improving the efficiency of spatial searches. Experimentation at the mapshaper website show 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