diff --git a/R/plot_nhdplus.R b/R/plot_nhdplus.R index 8d9f5ee6..41062be5 100644 --- a/R/plot_nhdplus.R +++ b/R/plot_nhdplus.R @@ -174,6 +174,9 @@ plot_nhdplus <- function(outlets = NULL, bbox = NULL, streamorder = NULL, cachedir = cache_tiles, verbose = FALSE, provider = basemap) + old_par <- par(mar = c(0, 0, 0, 0)) + on.exit(par(old_par)) + mapsf::mf_map(bb, type = "base", col = NA, border = NA) maptiles::plot_tiles(tiles, add = TRUE) diff --git a/docs/404.html b/docs/404.html index 1a7d860e..ccb745d0 100644 --- a/docs/404.html +++ b/docs/404.html @@ -12,7 +12,7 @@ - + @@ -39,7 +39,7 @@
@@ -122,7 +122,7 @@Now, we can use dataRetrieval @@ -159,7 +166,7 @@
+@@ -184,7 +123,7 @@+basin <- dataRetrieval::findNLDI(comid = comid, find = "basin") network <- get_3dhp(basin$basin, type = "flowline") @@ -170,27 +177,35 @@
#> polygon. #> Warning: No sink, spring, waterbody outlet features found #> Warning: No headwater, terminus, divergence, confluence, catchment outlet -#> features found in area of interest. - +#> features found in area of interest.
++down_mains <- get_3dhp(ids = dm, type = "flowline") old_par <- par(mar = c(0, 0, 0, 0)) plot_nhdplus(bbox = sf::st_bbox(basin$basin), flowline_only = TRUE, plot_config = list(flowline = list(col = NULL)), zoom = 10) - plot(pc(basin$basin), lwd = 2, add = TRUE) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set
-+plot(pc(basin$basin), lwd = 2, add = TRUE) plot(pc(network), lwd = 0.5, add = TRUE) plot(pc(water), lwd = 0.5, border = "skyblue", col = "lightblue", add = TRUE) plot(pc(hydrolocation), pch = "o", col = "#80808026", add = TRUE) plot(pc(down_mains), lwd = 3, col = "blue", add = TRUE)
+-par(old_par) old_par <- par(mar = c(0, 0, 0, 0)) plot(pc(down_mains)) plot(pc(basin$basin), add = TRUE)
++par(old_par)
Neat. Now we have flowlines, waterbodies, hydrologic locations, a basin boundary, and major rivers downstream to work with. These could be @@ -201,7 +216,7 @@
++reachcode <- "07070004002889" @@ -222,8 +237,9 @@
#> 2 07070004002889 <NA> <NA> 11 Reachcode End #> edhuniqueid workunitid geometry #> 1 <NA> <NA> POINT (-89.44179 43.48829) -#> 2 <NA> <NA> POINT (-89.43904 43.48568) - +#> 2 <NA> <NA> POINT (-89.43904 43.48568)
-+mainstem_points <- get_3dhp(ids = hydrolocation$mainstemid, type = "reach code, external connection") mainstem_lines <- get_3dhp(ids = hydrolocation$mainstemid, type = "flowline") @@ -231,17 +247,24 @@
plot(pc(hydrolocation), pch = "o", col = "#808080BF") plot(pc(mainstem_lines), lwd = 2, col = "blue", add = TRUE)
@@ -257,26 +257,52 @@++par(old_par) old_par <- par(mar = c(0, 0, 0, 0)) plot_nhdplus(bbox = sf::st_bbox(basin$basin), flowline_only = TRUE, plot_config = list(flowline = list(col = NULL)), zoom = 10) #> Zoom set to: 10 - plot(pc(mainstem_lines), lwd = 2, col = "blue", add = TRUE) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set
-+plot(pc(mainstem_lines), lwd = 2, col = "blue", add = TRUE) plot(pc(mainstem_points), pch = "o", col = "#808080BF", add = TRUE)
diff --git a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-1-1.png b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-1-1.png index bc6d94b0..8e71062d 100644 Binary files a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-1-1.png and b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-1-1.png differ diff --git a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-2-1.png index 54b68c49..7d180c1e 100644 Binary files a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-2-1.png and b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-3-2.png b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-3-2.png index 465e2d78..3fa3ef39 100644 Binary files a/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-3-2.png and b/docs/articles/get_3dhp_data_files/figure-html/unnamed-chunk-3-2.png differ diff --git a/docs/articles/get_data_overview.html b/docs/articles/get_data_overview.html index 3cb1bcf4..e7a35861 100644 --- a/docs/articles/get_data_overview.html +++ b/docs/articles/get_data_overview.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@+par(old_par)
With this functionality, we have what we need to inter operate between older NHD data and newly released 3DHP data. This service is @@ -265,7 +288,7 @@
-
Site built with pkgdown 2.0.7.
+Site built with pkgdown 2.0.9.
Network Linked Data Index integra flowline_only = FALSE, overwrite = TRUE) #> All intersections performed in latitude/longitude. #> Reading NHDFlowline_Network +#> Spherical geometry (s2) switched off +#> Spherical geometry (s2) switched on #> Writing NHDFlowline_Network #> Reading CatchmentSP +#> Spherical geometry (s2) switched off +#> Found invalid geometry, attempting to fix. +#> Spherical geometry (s2) switched on #> Writing CatchmentSP - +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on
++names(dataset) #> [1] "NHDFlowline_Network" "CatchmentSP" "NHDArea" -#> [4] "NHDWaterbody" "NHDFlowline_NonNetwork" - +#> [4] "NHDWaterbody" "NHDFlowline_NonNetwork"
++sapply(dataset, nrow) #> NHDFlowline_Network CatchmentSP NHDArea #> 389 370 20 #> NHDWaterbody NHDFlowline_NonNetwork -#> 473 8 - +#> 473 8
+#> Zoom set to: 10 +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set+old_par <- par(mar = c(0, 0, 0, 0)) plot_nhdplus(outlets = list(featureSource = "nwissite", featureID = "USGS-04074950"), nhdplus_data = demo_data, flowline_only = TRUE) -#> Zoom set to: 10
The above is the original way NHDPlusTools supported access NHDPlusV2 data. A dedicated web service subset utility is available in @@ -284,12 +310,17 @@
Network Linked Data Index integra calls behind the scenes.
Here we grab the basin for our site and request NHDPlus with its geometry as the Area of Interest.
-diff --git a/docs/reference/get_elev_along_path-1.png b/docs/reference/get_elev_along_path-1.png index ccb1c6c9..edebb904 100644 Binary files a/docs/reference/get_elev_along_path-1.png and b/docs/reference/get_elev_along_path-1.png differ diff --git a/docs/reference/get_elev_along_path.html b/docs/reference/get_elev_along_path.html index 829a176d..b0997ef4 100644 --- a/docs/reference/get_elev_along_path.html +++ b/docs/reference/get_elev_along_path.html @@ -1,5 +1,5 @@ -++basin <- get_nldi_basin(site) subset <- get_nhdplus(AOI = basin, realization = "flowline") - +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on
+par(mar = c(0, 0, 0, 0)) plot(sf::st_geometry(basin)) @@ -299,40 +330,53 @@
Network Linked Data Index integra
nhdplusTools
supports downloading four-digit Hydrologic Unit Code staged geodatabases. The functionget_huc()
is useful to discover the code needed here. -@@ -83463,7 +83463,7 @@++wolf_huc <- get_huc(basin, type = 'huc04') - +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on
++nrow(wolf_huc) -#> [1] 2 - +#> [1] 2
-+# it straddles hucs? Not really. par(mar = c(0, 0, 0, 0)) plot(sf::st_geometry(basin), col = "grey") plot(sf::st_geometry(wolf_huc), add = TRUE)
diff --git a/docs/reference/get_characteristics_metadata.html b/docs/reference/get_characteristics_metadata.html index 252d294c..a4b763a1 100644 --- a/docs/reference/get_characteristics_metadata.html +++ b/docs/reference/get_characteristics_metadata.html @@ -1,5 +1,5 @@ -++wolf_huc <- get_huc(site_feature, type = "huc04") - +#> Spherical geometry (s2) switched off +#> although coordinates are longitude/latitude, st_intersects assumes that they +#> are planar +#> Spherical geometry (s2) switched on
++nrow(wolf_huc) -#> [1] 1 - +#> [1] 1
-+# better!! par(mar = c(0, 0, 0, 0)) plot(sf::st_geometry(wolf_huc)) plot(sf::st_geometry(basin), col = "grey", add = TRUE)
++outdir <- file.path(nhdplusTools_data_dir(), "hr_access_demo") dir.create(outdir) #> Warning in dir.create(outdir): #> 'C:\Users\dblodgett\AppData\Roaming\R\data\R\nhdplusTools\hr_access_demo' -#> already exists - +#> already exists
@@ -135,7 +135,7 @@+download_dir <- download_nhdplushr(outdir, wolf_huc$huc4) list.files(download_dir) @@ -346,7 +390,7 @@
Network Linked Data Index integra which uses
make_standalone()
to ensure that the nhdplus attributes are complete and self-consistent within the subset of data returned. -diff --git a/docs/reference/get_catchment_characteristics.html b/docs/reference/get_catchment_characteristics.html index af1b8ca1..0b7b2438 100644 --- a/docs/reference/get_catchment_characteristics.html +++ b/docs/reference/get_catchment_characteristics.html @@ -1,5 +1,5 @@ -++nhdplushr <- get_nhdplushr( download_dir, @@ -361,8 +405,9 @@
Network Linked Data Index integra #> processing may be really slow. You can skip the processing by setting #> METHOD=SKIP, or only make it analyze counter-clock wise parts by setting #> METHOD=ONLY_CCW if you can assume that the outline of holes is counter-clock -#> wise defined - +#> wise defined
+sapply(nhdplushr, nrow) #> NHDFlowline NHDPlusCatchment NHDWaterbody #> 53834 51815 34138 @@ -384,7 +429,7 @@
Network Linked Data Index integra This attribute is merely a unique integer identifier and should not be assumed to relate to anything outside the context of a given dataset. -
@@ -108,7 +108,7 @@++nhdplushr <- get_hr_data(list.files(download_dir, pattern = ".gdb", full.names = TRUE), layer = "NHDFlowline", rename = TRUE) @@ -418,14 +463,16 @@
Network Linked Data Index integra #> [51] "MaxElevSmo" "MinElevSmo" #> [53] "Slope" "SlopeLenKm" #> [55] "ElevFixed" "HWType" -#> [57] "HWNodeSqKm" "StatusFlag" - +#> [57] "HWNodeSqKm" "StatusFlag"
++# Great Lakes coast are flowlines -- remove for visuals gl_coast <- c(get_DM(nhdplushr, 60002700000331), get_DM(nhdplushr, 60002700049157)) #> defaulting to comid rather than permanent_identifier -#> defaulting to comid rather than permanent_identifier - +#> defaulting to comid rather than permanent_identifier
-+plot_data <- dplyr::filter(nhdplushr, FCODE != 56600 & StreamOrde > 2 & !COMID %in% gl_coast) par(mar = c(0, 0, 0, 0)) @@ -433,7 +480,7 @@
Network Linked Data Index integra plot(sf::st_geometry(basin), col = "grey", add = TRUE) plot(sf::st_geometry(plot_data), lwd = plot_data$StreamOrde / 3, col = "blue", add = TRUE)
diff --git a/docs/reference/get_boundaries.html b/docs/reference/get_boundaries.html index d861d39b..3d3b36c5 100644 --- a/docs/reference/get_boundaries.html +++ b/docs/reference/get_boundaries.html @@ -1,5 +1,5 @@ -+par(mar = c(0, 0, 0, 0)) plot(sf::st_geometry(basin), col = "grey") @@ -443,7 +490,7 @@
Network Linked Data Index integra question…
-
get_flowline_index()
anddisambiguate_flowline_indexes()
are your friends.@@ -134,7 +134,7 @@++potential_matches <- get_flowline_index(nhdplushr, points = site_feature, @@ -453,16 +500,18 @@
Network Linked Data Index integra #> Warning in match_crs(x, points, paste("crs of lines and points don't match.", : #> crs of lines and points don't match. attempting st_transform of lines #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : -#> converting to LINESTRING, this may be slow, check results - +#> converting to LINESTRING, this may be slow, check results
++potential_matches #> id COMID REACHCODE REACH_meas offset #> 1 1 60002700035364 04030202000126 34.9737 0.0002166323 #> 2 1 60002700000908 04030104001542 49.1370 0.0177673341 #> 3 1 60002700036849 04030104001542 81.5378 0.0224609122 #> 4 1 60002700035750 04030104000533 31.4940 0.0244823037 -#> 5 1 60002700034888 04030104000136 100.0000 0.0247855142 - +#> 5 1 60002700034888 04030104000136 100.0000 0.0247855142
diff --git a/docs/reference/get_UT.html b/docs/reference/get_UT.html index 8439cc12..212d4106 100644 --- a/docs/reference/get_UT.html +++ b/docs/reference/get_UT.html @@ -1,5 +1,5 @@ -+site_meta <- dataRetrieval::readNWISsite(gsub("USGS-", "", site_feature$identifier)) sqmi_to_sqkm <- 2.59 @@ -480,20 +529,22 @@
Network Linked Data Index integra
If what you really need is the base NHD, which is now a static dataset, the pattern is just the same as with nhdplushr using
-download_nhd()
.++outdir <- file.path(nhdplusTools_data_dir(), "nhd_access_demo") dir.create(outdir) #> Warning in dir.create(outdir): #> 'C:\Users\dblodgett\AppData\Roaming\R\data\R\nhdplusTools\nhd_access_demo' -#> already exists - +#> already exists
++download_dir <- download_nhd(outdir, wolf_huc$huc4) list.files(download_dir) -#> [1] "NHD_H_0403_HU4_GDB.gdb" "NHD_H_0403_HU4_GDB.jpg" "NHD_H_0403_HU4_GDB.xml" - +#> [1] "NHD_H_0403_HU4_GDB.gdb" "NHD_H_0403_HU4_GDB.jpg" "NHD_H_0403_HU4_GDB.xml"
++nhd_gdb <- list.files(download_dir, pattern = ".gdb", full.names = TRUE) sf::st_layers(nhd_gdb) @@ -584,8 +635,9 @@
Network Linked Data Index integra #> 39 <NA> #> 40 <NA> #> 41 <NA> -#> 42 <NA> - +#> 42 <NA>
+nhd_fline <- sf::read_sf(nhd_gdb, "NHDFlowline")
We’ll wait to plot this up until after we’ve done some work with 3DHP. As of writing, the 3DHP is more or less the same as the NHD but in @@ -593,17 +645,20 @@
Network Linked Data Index integra pull data for subsets much the same as the other
get_*
functions. Seevignette("get_3dhp_data.Rmd")
for more on how to work with 3DHP data. -@@ -144,7 +144,7 @@++sub_3dhp <- get_3dhp(basin, type = "flowline") - +#> Getting features 0 to 2000 of 2199 +#> Getting features 2000 to 2199 of 2199
-+plot(sub_3dhp) #> Warning: plotting the first 10 out of 35 attributes; use max.plot = 35 to plot #> all
diff --git a/docs/reference/get_UM.html b/docs/reference/get_UM.html index db8f0ece..3c6d7644 100644 --- a/docs/reference/get_UM.html +++ b/docs/reference/get_UM.html @@ -1,5 +1,5 @@ -+-sub_3dhp <- st_compatibalize(sub_3dhp, nhd_fline) +sub_3dhp <- st_compatibalize(sub_3dhp, nhd_fline) par(mar = c(0, 0, 0, 0)) plot(sf::st_geometry(basin), col = "grey") @@ -615,7 +670,7 @@
Network Linked Data Index integra provides easy access to representations of datasets that people use to cross reference other data.
discover_geoconnex_reference()
provides access to a full table of what’s available. -@@ -144,7 +144,7 @@++unique(discover_geoconnex_reference()[c("id", "title")]) #> # A tibble: 18 × 2 @@ -643,17 +698,19 @@
uses numeric or character attributes to attempt to determine the best flowline match when many near by matches exist. This is especially useful for mainstem / -tributary disambiguation. -Network Linked Data Index integra a persistent way to identify these features and will always lead you back to a representation of the feature when you look it up.
For example, let’s get a subset of data for our Wolf River basin.
-@@ -124,14 +124,14 @@++wolf_gages <- get_geoconnex_reference(basin, type = "gages") -#> Starting download of first 1000 features. - +#> Starting download of first set of features.
++geoconnex_gage <- dplyr::filter(wolf_gages, provider_id == gsub("USGS-", "", site_feature$identifier)) wolf_mainstems <- get_geoconnex_reference(basin, type = "mainstems") -#> Starting download of first 1000 features. - +#> Starting download of first set of features.
diff --git a/docs/articles/indexing.html b/docs/articles/indexing.html index badb9e72..5bec5fa4 100644 --- a/docs/articles/indexing.html +++ b/docs/articles/indexing.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@+wolf_mainstem <- dplyr::filter(wolf_mainstems, uri == geoconnex_gage$mainstem_uri) par(mar = c(0, 0, 0, 0)) @@ -670,7 +727,7 @@
Network Linked Data Index integra of the NHDPlusV2, a snapshot available as part of and retrieved with
get_huc()
, and the latest (soon to be final) snapshot available usingdownload_wbd()
. -++wbd_dir <- file.path(nhdplusTools_data_dir(), "wbd_access_demo") @@ -679,8 +736,9 @@
Network Linked Data Index integra #> Extracting data ... #> Error in zip::unzip(file, exdir = outdir, overwrite = FALSE) : #> zip error: Cannot open zip file `C:\Users\dblodgett\AppData\Roaming\R\data\R\nhdplusTools\wbd_access_demo\WBD_National_GDB.zip` for reading in file zip.c:141 -#> WBD data extracted to: C:\Users\dblodgett\AppData\Roaming/R/data/R/nhdplusTools/wbd_access_demo/WBD_National_GDB.gdb - +#> WBD data extracted to: C:\Users\dblodgett\AppData\Roaming/R/data/R/nhdplusTools/wbd_access_demo/WBD_National_GDB.gdb
@@ -97,7 +97,7 @@+# zip::unzip doesn't always work if(length(wbd_out == 0)) { f <- list.files(wbd_dir, pattern = ".zip", full.names = TRUE) @@ -755,7 +813,7 @@
Network Linked Data Index integra diff --git a/docs/articles/index.html b/docs/articles/index.html index 02f51741..9b4c9e21 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,5 +1,5 @@ -
Articles • nhdplusTools Articles • nhdplusTools @@ -17,7 +17,7 @@All vignettes
Introductiondisambiguate_flowline_indexes()
get_hydro_location()
retrieves +tributary disambiguation. -get_hydro_location()
retrieves the point location of an index along a flowline. - -rescale_measures()
converts 0:100 reachcode measures to -0:100 flowline measures. -get_partial_length()
retrieves a +rescale_measures()
converts 0:100 reachcode measures to +0:100 flowline measures. -get_partial_length()
retrieves a partial length (upstream and downstream) of an index location. -get_path_lengths()
retrieves the distance between the outlets of pairs of flowlines. Use with -get_partial_length()
to determine network distance between +get_partial_length()
to determine network distance between indexes.For waterbody indexes, the
@@ -168,8 +168,9 @@get_wb_outlet()
function is helpful too determine which flowline is the outlet of a waterbody.Flowline Indexing= units::set_units(200, "meters"), max_matches = 1) #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : -#> converting to LINESTRING, this may be slow, check results - +#> converting to LINESTRING, this may be slow, check results
diff --git a/docs/reference/download_wbd.html b/docs/reference/download_wbd.html index a899d2ca..19546ffc 100644 --- a/docs/reference/download_wbd.html +++ b/docs/reference/download_wbd.html @@ -1,5 +1,5 @@ -+indexes <- left_join(sf::st_sf(id = c(1:nrow(gages)), geom = sf::st_geometry(gages)), indexes, by = "id") @@ -181,17 +182,19 @@
did. The below shows the percent of COMIDs and REACHCODEs that match and shows a histogram of the measure differences for the REACHCODEs that were matched. -Flowline Indexingget_flowline_index()
++p_match <- 100 * length(which(indexes$COMID %in% gages$FLComID)) / nrow(gages) paste0(round(p_match, digits = 1), "% were found to match the COMID in the NHDPlus gages layer") -#> [1] "58.7% were found to match the COMID in the NHDPlus gages layer" - +#> [1] "58.7% were found to match the COMID in the NHDPlus gages layer"
++p_match <- 100 * length(which(indexes$REACHCODE %in% gages$REACHCODE)) / nrow(gages) paste0(round(p_match, digits = 1), "% were found to match the REACHCODE in the NHDPlus gages layer") -#> [1] "60.9% were found to match the REACHCODE in the NHDPlus gages layer" - +#> [1] "60.9% were found to match the REACHCODE in the NHDPlus gages layer"
-+matched <- cbind(indexes, dplyr::select(sf::st_drop_geometry(gages), REACHCODE_ref = REACHCODE, @@ -203,7 +206,7 @@
Flowline Indexinghist(matched$REACH_meas_diff, breaks = 100, main = "Difference in measure for gages matched to the same reach.")
@@ -134,7 +134,7 @@+diff --git a/docs/reference/download_rf1.html b/docs/reference/download_rf1.html index 062549d4..82714c7c 100644 --- a/docs/reference/download_rf1.html +++ b/docs/reference/download_rf1.html @@ -1,5 +1,5 @@ -round(quantile(matched$REACH_meas_diff, probs = c(0, 0.1, 0.25, 0.5, 0.75, 0.9, 1)), @@ -224,28 +227,30 @@
Flowline Indexing with higher p fly. Also note, we are working in units of degrees for this sample. (this is probably not a good way to do things, but is being shown here for the sake of demonstration) -
++indexes <- get_flowline_index(flowlines, sf::st_geometry(gages), search_radius = units::set_units(0.1, "degrees"), precision = 10) #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : -#> converting to LINESTRING, this may be slow, check results -#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE - +#> converting to LINESTRING, this may be slow, check results
+indexes <- left_join(data.frame(id = seq_len(nrow(gages))), indexes, by = "id")
Now lets look at out comparison again.
-@@ -141,7 +141,7 @@++p_match <- 100 * length(which(indexes$COMID %in% gages$FLComID)) / nrow(gages) paste0(round(p_match, digits = 1), "% were found to match the COMID in the NHDPlus gages layer") -#> [1] "76.1% were found to match the COMID in the NHDPlus gages layer" - +#> [1] "76.1% were found to match the COMID in the NHDPlus gages layer"
++p_match <- 100 * length(which(indexes$REACHCODE %in% gages$REACHCODE)) / nrow(gages) paste0(round(p_match, digits = 1), "% were found to match the REACHCODE in the NHDPlus gages layer") -#> [1] "76.1% were found to match the REACHCODE in the NHDPlus gages layer" - +#> [1] "76.1% were found to match the REACHCODE in the NHDPlus gages layer"
-+matched <- cbind(indexes, dplyr::select(sf::st_set_geometry(gages, NULL), REACHCODE_ref = REACHCODE, @@ -257,7 +262,7 @@
Flowline Indexing with higher p hist(matched$REACH_meas_diff, breaks = 100, main = "Difference in measure for gages matched to the same reach.")
diff --git a/docs/reference/download_nhdplusv2.html b/docs/reference/download_nhdplusv2.html index fdd394d4..0db29774 100644 --- a/docs/reference/download_nhdplusv2.html +++ b/docs/reference/download_nhdplusv2.html @@ -1,5 +1,5 @@ -+round(quantile(matched$REACH_meas_diff, probs = c(0, 0.1, 0.25, 0.5, 0.75, 0.9, 1)), digits = 2) @@ -274,14 +279,15 @@
Finding multiple indexes
For this example, we’ll just look at one point but keep all the sites for disambiguation down below.
-@@ -141,7 +162,7 @@++all_indexes <- get_flowline_index(flowlines, sf::st_geometry(gages), search_radius = units::set_units(0.01, "degrees"), max_matches = 10) #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : -#> converting to LINESTRING, this may be slow, check results - +#> converting to LINESTRING, this may be slow, check results
-+indexes <- left_join(sf::st_sf(id = 42, geom = sf::st_geometry(gages)[42]), all_indexes[all_indexes$id == 42, ], by = "id") @@ -290,7 +296,7 @@
Finding multiple indexesplot(sf::st_geometry(indexes), add = TRUE) plot(sf::st_geometry(sf::st_zm(flowlines)), col = "blue", add = TRUE)
+@@ -78,7 +78,7 @@indexes #> Simple feature collection with 10 features and 5 fields #> Geometry type: POINT @@ -328,7 +334,7 @@
Finding multiple indexesBelow, we run
disambiguate_flowline_indexes()
on all the indexes we found then pull out the one we looked at just above as an example (gage 42 in our list). -diff --git a/docs/reference/download_nhdplushr.html b/docs/reference/download_nhdplushr.html index f7a04158..bebffa24 100644 --- a/docs/reference/download_nhdplushr.html +++ b/docs/reference/download_nhdplushr.html @@ -1,5 +1,5 @@ -+-unique_indexes <- disambiguate_flowline_indexes( all_indexes, flowlines[, c("COMID", "TotDASqKM"), drop = TRUE], @@ -346,7 +352,7 @@
Finding multiple indexesplot(sf::st_geometry(sf::st_zm(flowlines[flowlines$COMID %in% unique_index$COMID,])), col = "blue", add = TRUE)
+@@ -141,7 +141,7 @@unique_index #> Simple feature collection with 1 feature and 5 fields @@ -380,7 +386,7 @@
Waterbody Indexing
+@@ -68,13 +69,14 @@waterbody <- sf::read_sf(nhdplus_path(), "NHDWaterbody") gages <- sf::st_drop_geometry(gages) %>% @@ -394,7 +400,7 @@
andWaterbody Indexingget_flowline_index()
get_waterbody_index()
and what the output looks like. -+++flowline_indexes <- left_join(data.frame(id = seq_len(nrow(gages))), get_flowline_index( @@ -402,8 +408,9 @@
Waterbody Indexingsf::st_geometry(sf::st_transform(gages, 5070)), search_radius = units::set_units(200, "m")), by = "id") #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : -#> converting to LINESTRING, this may be slow, check results - +#> converting to LINESTRING, this may be slow, check results
-+indexed_gages <- cbind(dplyr::select(gages, orig_REACHCODE = REACHCODE, orig_Measure = Measure, @@ -420,7 +427,7 @@
Waterbody Indexingplot(sf::st_geometry(waterbody), add = TRUE) plot(sf::st_geometry(indexed_gages), add = TRUE)
@@ -121,7 +121,6 @@+diff --git a/docs/articles/nhdplusTools.html b/docs/articles/nhdplusTools.html index ff50df0f..4b0a7e21 100644 --- a/docs/articles/nhdplusTools.html +++ b/docs/articles/nhdplusTools.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@dplyr::select(sf::st_drop_geometry(indexed_gages), near_wb_COMID, near_wb_dist, in_wb_COMID, outlet_fline_COMID) #> near_wb_COMID near_wb_dist in_wb_COMID outlet_fline_COMID @@ -489,7 +496,7 @@
Waterbody Indexing -
Site built with pkgdown 2.0.7.
+Site built with pkgdown 2.0.9.
TL;DR library(nhdplusTools) library(sf) -#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE start_point <- st_sfc(st_point(c(-89.362239, 43.090266)), crs = 4269) start_comid <- discover_nhdplus_id(start_point) @@ -145,8 +144,9 @@
TL;DR #> Reading CatchmentSP #> Spherical geometry (s2) switched off #> Spherical geometry (s2) switched on -#> Writing CatchmentSP - +#> Writing CatchmentSP
diff --git a/docs/reference/discover_nldi_characteristics.html b/docs/reference/discover_nldi_characteristics.html index e191530e..37aabc52 100644 --- a/docs/reference/discover_nldi_characteristics.html +++ b/docs/reference/discover_nldi_characteristics.html @@ -1,5 +1,6 @@ -+flowline <- subset$NHDFlowline_Network catchment <- subset$CatchmentSP waterbody <- subset$NHDWaterbody @@ -164,12 +164,18 @@
TL;DR
Or fetch NWIS an site as the starting point and generate a plot. Data is returned and/or stored in a local file for later use.
-++#> Zoom set to: 11 +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set# ?plot_nhdplus for more plot_data <- plot_nhdplus( outlets = list(featureSource = "nwissite", featureID = "USGS-05428500"), gpkg = subset_file, overwrite = TRUE) -#> Zoom set to: 11
This vignette covers a range of utilities the nhdplusTools package offers for working with data in a U.S. context.
@@ -183,7 +189,7 @@TL;DR aware of. Once you have it downloaded and extracted, you can tell the nhdplusTools package where it is with the
nhdplus_path()
function. -+@@ -146,7 +146,7 @@nhdplus_path(file.path(work_dir, "natseamless.gpkg")) basename(nhdplus_path()) @@ -193,7 +199,7 @@
TL;DR specific NHDPlus attributes with very little overhead. It also supports access to an updated set of network attributes that incorporate numerous network updates from national hydrologic modeling projects. -
diff --git a/docs/reference/discover_geoconnex_reference.html b/docs/reference/discover_geoconnex_reference.html index dee39aac..1031eecf 100644 --- a/docs/reference/discover_geoconnex_reference.html +++ b/docs/reference/discover_geoconnex_reference.html @@ -1,5 +1,5 @@ -++vaa <- get_vaa() names(vaa) #> [1] "comid" "streamleve" "streamorde" "streamcalc" "fromnode" @@ -204,8 +210,9 @@
TL;DR #> [26] "lengthkm" "fcode" "vpuin" "vpuout" "areasqkm" #> [31] "totdasqkm" "divdasqkm" "totma" "wbareatype" "pathtimema" #> [36] "slope" "slopelenkm" "ftype" "gnis_name" "gnis_id" -#> [41] "wbareacomi" "hwnodesqkm" "rpuid" "vpuid" "roughness" -nrow(vaa) +#> [41] "wbareacomi" "hwnodesqkm" "rpuid" "vpuid" "roughness"
+nrow(vaa) #> [1] 2691339
@@ -275,7 +291,7 @@NHDPlus HiRes @@ -222,12 +229,13 @@
NHDPlus HiRes
++download_nhdplushr(nhd_dir = "download_dir", hu_list = c("0101"), # can mix hu02 and hu04 codes. download_files = FALSE) # TRUE will download files. -#> [1] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0101_HU4_20220901_GDB.zip" - +#> [1] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0101_HU4_20220901_GDB.zip"
++out_gpkg <- file.path(work_dir, "nhd_hr.gpkg") hr_data <- get_nhdplushr(work_dir, out_gpkg = out_gpkg) @@ -237,9 +245,16 @@
NHDPlus HiRes#> layer_name geometry_type features fields crs_name #> 1 NHDFlowline Line String 2691 57 GRS 1980(IUGG, 1980) #> 2 NHDPlusCatchment Multi Polygon 2603 7 GRS 1980(IUGG, 1980) -names(hr_data) -#> [1] "NHDFlowline" "NHDPlusCatchment" -unlink(out_gpkg) +#> 3 NHDWaterbody Polygon 1044 15 GRS 1980(IUGG, 1980) +#> 4 NHDArea Polygon 10 14 GRS 1980(IUGG, 1980) +#> 5 NHDLine Line String 142 12 GRS 1980(IUGG, 1980) +#> 6 NHDPlusSink Point 1 10 GRS 1980(IUGG, 1980) +#> 7 NHDPoint 3D Point 7 10 GRS 1980(IUGG, 1980)
++names(hr_data) +#> [1] "NHDFlowline" "NHDPlusCatchment"
++unlink(out_gpkg) hr_data <- get_nhdplushr(work_dir, out_gpkg = out_gpkg, @@ -254,8 +269,9 @@
NHDPlus HiRes#> 4 NHDArea Polygon 10 14 GRS 1980(IUGG, 1980) #> 5 NHDLine Line String 142 12 GRS 1980(IUGG, 1980) #> 6 NHDPlusSink Point 1 10 GRS 1980(IUGG, 1980) -#> 7 NHDPoint 3D Point 7 10 GRS 1980(IUGG, 1980) -names(hr_data) +#> 7 NHDPoint 3D Point 7 10 GRS 1980(IUGG, 1980)
+names(hr_data) #> [1] "NHDFlowline" "NHDPlusCatchment" "NHDWaterbody" "NHDArea" #> [5] "NHDLine" "NHDPlusSink" "NHDPoint"
Discovery and Subsettingdiscover_nhdplus_id() First, let’s look at a given point location. Then see where it is relative to our flowlines. -
+@@ -201,7 +201,7 @@lon <- -89.36 lat <- 43.09 @@ -294,7 +310,7 @@
for more on this functionality. -Discovery and Subsettingget_raindrop_trace()
diff --git a/docs/reference/calculate_arbolate_sum.html b/docs/reference/calculate_arbolate_sum.html index eed497b5..afe9aa03 100644 --- a/docs/reference/calculate_arbolate_sum.html +++ b/docs/reference/calculate_arbolate_sum.html @@ -1,5 +1,5 @@ -++start_comid <- discover_nhdplus_id(start_point, raindrop = TRUE) start_comid #> Simple feature collection with 2 features and 7 fields @@ -307,8 +323,9 @@
Discovery and Subsetting#> <chr> <chr> <int> <chr> <dbl> <dbl> <list> #> 1 nhdF… Yahara R… 1.33e7 07090002… 124. 40.1 <dbl [2]> #> 2 rain… NA NA NA NA NA <dbl [0]> -#> # ℹ 1 more variable: geometry <LINESTRING [°]> - +#> # ℹ 1 more variable: geometry <LINESTRING [°]>
@@ -330,15 +347,16 @@+plot(sf::st_geometry(start_comid)) plot(sf::st_geometry(flowline), add = TRUE, col = "blue", lwd = 2) plot(start_point, cex = 1.5, lwd = 2, col = "red", add = TRUE)
Web Service Data Subsetting
++dataRetrieval::get_nldi_sources()$source #> [1] "ca_gages" "census2020-nhdpv2" "epa_nrsa" #> [4] "geoconnex-demo" "gfv11_pois" "huc12pp" #> [7] "huc12pp_102020" "nmwdi-st" "npdes" #> [10] "nwisgw" "nwissite" "ref_dams" #> [13] "ref_gage" "vigil" "wade" -#> [16] "WQP" "comid" - +#> [16] "WQP" "comid"
+nldi_feature <- list(featureSource = "comid", featureID = as.integer(start_comid$comid)[1]) @@ -357,7 +375,7 @@
Web Service Data Subsetting
+@@ -176,7 +176,7 @@flowline_nldi <- navigate_nldi(nldi_feature, mode = "upstreamTributaries", distance_km = 1000) @@ -372,7 +390,7 @@
function that will replaceWeb Service Data Subsettingnavigate_network()
navigate_nldi()
andsubset_nhdplus()
for many use cases. -diff --git a/docs/reference/align_nhdplus_names.html b/docs/reference/align_nhdplus_names.html index e1bed9e1..d64bb186 100644 --- a/docs/reference/align_nhdplus_names.html +++ b/docs/reference/align_nhdplus_names.html @@ -1,5 +1,5 @@ -++output_file_download <- file.path(work_dir, "subset_download.gpkg") output_file_download <-subset_nhdplus(comids = as.integer(flowline_nldi$UT$nhdplus_comid), @@ -381,14 +399,16 @@
Web Service Data Subsetting= TRUE) #> All intersections performed in latitude/longitude. #> Reading NHDFlowline_Network -#> Writing NHDFlowline_Network - +#> Writing NHDFlowline_Network
++sf::st_layers(output_file_download) #> Driver: GPKG #> Available layers: #> layer_name geometry_type features fields crs_name -#> 1 NHDFlowline_Network Line String 168 137 NAD83 - +#> 1 NHDFlowline_Network Line String 168 137 NAD83
+flowline_download <- sf::read_sf(file.path(work_dir, "subset_download.gpkg"), "NHDFlowline_Network") @@ -405,7 +425,7 @@
Web Service Data Subsetting
++nldi_feature <- list(featureSource = "nwissite", featureID = "USGS-05428500") @@ -421,14 +441,16 @@
Web Service Data Subsetting= FALSE, overwrite = TRUE) #> All intersections performed in latitude/longitude. #> Reading NHDFlowline_Network -#> Writing NHDFlowline_Network - +#> Writing NHDFlowline_Network
++sf::st_layers(output_file_download) #> Driver: GPKG #> Available layers: #> layer_name geometry_type features fields crs_name -#> 1 NHDFlowline_Network Line String 168 137 NAD83 - +#> 1 NHDFlowline_Network Line String 168 137 NAD83
@@ -181,7 +167,7 @@+flowline_nwis <- sf::read_sf(output_file_nwis, "NHDFlowline_Network") @@ -457,7 +479,7 @@
Local Data Subsetting -
+UT_comids <- get_UT(flowline, start_comid$comid[1]) UT_comids #> [1] 13293380 13293384 13293388 13293392 13293398 13293424 13293430 @@ -489,7 +511,7 @@
Local Data Subsettingfline
sf
data.frame
and plot it with our other layers. -@@ -151,22 +151,8 @@+diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index ade10203..a535a3b3 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,5 +1,5 @@ -pandoc: 3.1.1 -pkgdown: 2.0.7 +pandoc: '3.2' +pkgdown: 2.0.9 pkgdown_sha: ~ articles: get_3dhp_data: get_3dhp_data.html @@ -8,7 +8,7 @@ articles: nhdplushr: nhdplushr.html nhdplusTools: nhdplusTools.html plot_nhdplus: plot_nhdplus.html -last_built: 2024-05-22T21:02Z +last_built: 2024-08-01T15:01Z urls: reference: https://doi-usgs.github.io/nhdplusTools/reference article: https://doi-usgs.github.io/nhdplusTools/articles diff --git a/docs/reference/Rplot003.png b/docs/reference/Rplot003.png index 8335b45e..12d5b8fd 100644 Binary files a/docs/reference/Rplot003.png and b/docs/reference/Rplot003.png differ diff --git a/docs/reference/Rplot004.png b/docs/reference/Rplot004.png index 9edab80d..e73db21a 100644 Binary files a/docs/reference/Rplot004.png and b/docs/reference/Rplot004.png differ diff --git a/docs/reference/Rplot005.png b/docs/reference/Rplot005.png index f56fad58..efbccfcc 100644 Binary files a/docs/reference/Rplot005.png and b/docs/reference/Rplot005.png differ diff --git a/docs/reference/Rplot006.png b/docs/reference/Rplot006.png index 9e86bd19..e6a0abb9 100644 Binary files a/docs/reference/Rplot006.png and b/docs/reference/Rplot006.png differ diff --git a/docs/reference/Rplot007.png b/docs/reference/Rplot007.png index 363e9e36..fd1749f2 100644 Binary files a/docs/reference/Rplot007.png and b/docs/reference/Rplot007.png differ diff --git a/docs/reference/Rplot008.png b/docs/reference/Rplot008.png index 239fe4e5..8c68e437 100644 Binary files a/docs/reference/Rplot008.png and b/docs/reference/Rplot008.png differ diff --git a/docs/reference/Rplot009.png b/docs/reference/Rplot009.png index ff87196e..159aff77 100644 Binary files a/docs/reference/Rplot009.png and b/docs/reference/Rplot009.png differ diff --git a/docs/reference/Rplot010.png b/docs/reference/Rplot010.png index 6a2b7e84..10b85058 100644 Binary files a/docs/reference/Rplot010.png and b/docs/reference/Rplot010.png differ diff --git a/docs/reference/Rplot011.png b/docs/reference/Rplot011.png index 6bfa61e1..4eb73896 100644 Binary files a/docs/reference/Rplot011.png and b/docs/reference/Rplot011.png differ diff --git a/docs/reference/add_plus_network_attributes.html b/docs/reference/add_plus_network_attributes.html index 5d56c358..4fade4d0 100644 --- a/docs/reference/add_plus_network_attributes.html +++ b/docs/reference/add_plus_network_attributes.html @@ -1,5 +1,5 @@ -plot(sf::st_geometry(flowline)) plot(start_point, cex = 1.5, lwd = 2, col = "red", add = TRUE) plot(sf::st_geometry(dplyr::filter(flowline, comid %in% UT_comids)), @@ -502,7 +524,7 @@
Local Data Subsetting -
++output_file <- file.path(work_dir, "subset.gpkg") output_file <-subset_nhdplus(comids = UT_comids, @@ -525,8 +547,9 @@
Local Data Subsetting#> Reading Gage #> Writing Gage #> Reading Sink -#> No features to write in Sink - +#> No features to write in Sink
+sf::st_layers(output_file) #> Driver: GPKG #> Available layers: @@ -541,7 +564,7 @@
Local Data Subsetting -
++ comid = list(col = "green")))) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be setcatchment <- sf::read_sf(output_file, "CatchmentSP") waterbody <- sf::read_sf(output_file, "NHDWaterbody") @@ -563,14 +586,14 @@
IndexingUsing the data above, we can use the
get_flowline_index()
function to get the comid, reachcode, and measure of our starting point like this. -+get_flowline_index(flowline, start_point) #> id COMID REACHCODE REACH_meas offset #> 1 1 13293750 07090002007373 41.8 0.0009619865
-
get_flowline_index()
will work with a list of points too. For demonstration purposes, we can use the gages in our subset from above.@@ -124,7 +124,6 @@+diff --git a/docs/articles/nhdplusTools_files/figure-html/tldr2-1.png b/docs/articles/nhdplusTools_files/figure-html/tldr2-1.png index b2b5aa50..6536bb57 100644 Binary files a/docs/articles/nhdplusTools_files/figure-html/tldr2-1.png and b/docs/articles/nhdplusTools_files/figure-html/tldr2-1.png differ diff --git a/docs/articles/nhdplushr.html b/docs/articles/nhdplushr.html index 699959e9..80d9f336 100644 --- a/docs/articles/nhdplushr.html +++ b/docs/articles/nhdplushr.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@gage <- sf::read_sf(output_file, "Gage") get_flowline_index(flowline, sf::st_geometry(gage), precision = 10) @@ -620,7 +643,7 @@
Indexing -
Site built with pkgdown 2.0.7.
+Site built with pkgdown 2.0.9.
TL;DR;
+#> Zoom set to: 11 +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be setlibrary(nhdplusTools) library(sf) -#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE work_dir <- file.path(nhdplusTools_data_dir(), "hr_v_cache") @@ -135,7 +134,13 @@
TL;DR; # Make a plot and get some background NHDPlusV2 data. plot_data <- plot_nhdplus(list("nwissite", "USGS-05428500"), streamorder = 3, nhdplus_data = sample_data) -#> Zoom set to: 11
+@@ -144,7 +149,6 @@
TL;DR; # Download some NHDPlusHR Data hr_data_dir <- download_nhdplushr(work_dir, hu04) -#> | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |== | 4% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% | |============ | 16% | |============ | 17% | |============ | 18% | |============= | 18% | |============= | 19% | |============== | 19% | |============== | 20% | |============== | 21% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |================ | 24% | |================= | 24% | |================= | 25% | |================== | 25% | |================== | 26% | |=================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |===================== | 31% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================= | 34% | |======================== | 34% | |======================== | 35% | |========================= | 35% | |========================= | 36% | |========================== | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 42% | |============================== | 43% | |============================== | 44% | |=============================== | 44% | |=============================== | 45% | |================================ | 45% | |================================ | 46% | |================================= | 46% | |================================= | 47% | |================================= | 48% | |================================== | 48% | |================================== | 49% | |=================================== | 49% | |=================================== | 50% | |=================================== | 51% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |===================================== | 54% | |====================================== | 54% | |====================================== | 55% | |======================================= | 55% | |======================================= | 56% | |======================================== | 56% | |======================================== | 57% | |======================================== | 58% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |========================================== | 61% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================ | 64% | |============================================= | 64% | |============================================= | 65% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 72% | |=================================================== | 73% | |=================================================== | 74% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 79% | |======================================================== | 80% | |======================================================== | 81% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 82% | |========================================================== | 83% | |========================================================== | 84% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 86% | |============================================================= | 87% | |============================================================= | 88% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================= | 94% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100% # Projection and simplification for demo purposes. hr <- get_nhdplushr(work_dir, out_gpkg = hr_gpkg, @@ -159,11 +163,13 @@
TL;DR; #> Warning in index_points_to_lines.hy(x, points, search_radius = search_radius, : #> converting to LINESTRING, this may be slow, check results #> id COMID REACHCODE REACH_meas offset -#> 1 1 22001000032700 07090002006114 37.6572 87.71874 - +#> 1 1 22001000032700 07090002006114 37.6572 87.71874
++ids <- get_UT(hr$NHDFlowline, start_index$COMID) -#> defaulting to comid rather than permanent_identifier - +#> defaulting to comid rather than permanent_identifier
+hr_subset <- subset_nhdplus(ids, nhdplus_data = hr_gpkg) #> All intersections performed in latitude/longitude. #> Reading NHDFlowline @@ -178,13 +184,20 @@
TL;DR; and see what it looks like. This plot uses NHDPlusV2 as returned by
plot_nhdplus()
as a base layer and adds NHDPlusHR data on top of it. -+plot_nhdplus(start_point) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set++plot_nhdplus(list("nwissite", "USGS-05428500"), streamorder = 2, nhdplus_data = sample_data, overwrite = TRUE, plot_config = list(flowline = list(lwd = 2.5), basin = list(lwd = 3))) #> Zoom set to: 11 - +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set
+plot(st_geometry(hr$NHDPlusCatchment), lwd = 0.25, add = TRUE) plot(st_geometry(hr$NHDFlowline), col = "blue", lwd = 0.5, add = TRUE) @@ -208,13 +221,14 @@
Download
Note: Data for each HU02 are put in their own output folder.
-++(hr_urls <- download_nhdplushr(work_dir, "06", download_files = FALSE)) #> [1] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0601_HU4_20220418_GDB.zip" #> [2] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0602_HU4_20220418_GDB.zip" #> [3] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0603_HU4_20220418_GDB.zip" -#> [4] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0604_HU4_20220418_GDB.zip" - +#> [4] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0604_HU4_20220418_GDB.zip"
+# already downloaded: list.files(hr_data_dir) #> [1] "NHDPLUS_H_0709_HU4_GDB.gdb" "NHDPLUS_H_0709_HU4_GDB.jpg" @@ -237,36 +251,40 @@
Basic functionalityget_nhdplushr()
First, if we just give it a directory containing HR data, it will give us back a list with flowlines and catchments as sf data.frames.
-+++#> [4,] "data.frame" "data.frame"hr <- get_nhdplushr(hr_data_dir) sapply(hr, class) #> NHDFlowline NHDPlusCatchment #> [1,] "sf" "sf" #> [2,] "tbl_df" "tbl_df" #> [3,] "tbl" "tbl" -#> [4,] "data.frame" "data.frame" -plot(st_geometry(hr$NHDFlowline), lwd = (hr$NHDFlowline$StreamOrde / 6))
+plot(st_geometry(hr$NHDFlowline), lwd = (hr$NHDFlowline$StreamOrde / 6))
If we want more data, we can get any of the layer options listed in the
-get_nhdplushr()
documentation.@@ -133,18 +133,36 @@++hr <- get_nhdplushr(hr_data_dir, layers = c("NHDFlowline", "NHDWaterbody", "NHDArea")) #> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL #> Message 1: organizePolygons() received a polygon with more than 100 parts. The #> processing may be really slow. You can skip the processing by setting #> METHOD=SKIP, or only make it analyze counter-clock wise parts by setting #> METHOD=ONLY_CCW if you can assume that the outline of holes is counter-clock -#> wise defined -sapply(hr, class) +#> wise defined
++sapply(hr, class) #> NHDFlowline NHDWaterbody NHDArea #> [1,] "sf" "sf" "sf" #> [2,] "tbl_df" "tbl_df" "tbl_df" #> [3,] "tbl" "tbl" "tbl" -#> [4,] "data.frame" "data.frame" "data.frame" -sapply(hr, nrow) +#> [4,] "data.frame" "data.frame" "data.frame"
++sapply(hr, nrow) #> NHDFlowline NHDWaterbody NHDArea -#> 34532 11444 499 -plot(st_geometry(hr$NHDFlowline), lwd = (hr$NHDFlowline$StreamOrde / 6), col = "blue") +#> 34532 11444 499
@@ -274,7 +292,7 @@+plot(st_geometry(hr$NHDFlowline), lwd = (hr$NHDFlowline$StreamOrde / 6), col = "blue") plot(c(st_geometry(hr$NHDWaterbody), st_geometry(hr$NHDArea)), col = "cyan", border = "cyan", lwd = 0.25, add = TRUE)
Basic functionality
+diff --git a/docs/articles/nhdplushr_files/figure-html/plot-1.png b/docs/articles/nhdplushr_files/figure-html/plot-1.png index 7860ab14..6e1f3c92 100644 Binary files a/docs/articles/nhdplushr_files/figure-html/plot-1.png and b/docs/articles/nhdplushr_files/figure-html/plot-1.png differ diff --git a/docs/articles/nhdplushr_files/figure-html/tldr-1.png b/docs/articles/nhdplushr_files/figure-html/tldr-1.png index bbdfca31..1df8317f 100644 Binary files a/docs/articles/nhdplushr_files/figure-html/tldr-1.png and b/docs/articles/nhdplushr_files/figure-html/tldr-1.png differ diff --git a/docs/articles/plot_nhdplus.html b/docs/articles/plot_nhdplus.html index 6ff3556c..c375f3a3 100644 --- a/docs/articles/plot_nhdplus.html +++ b/docs/articles/plot_nhdplus.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@demo_gpkg <- file.path(work_dir, "demo.gpkg") hr <- get_nhdplushr(hr_data_dir, out_gpkg = demo_gpkg) st_layers(demo_gpkg) @@ -301,22 +319,24 @@
all related attributes upstream are also fixed such that the network is intact for further use. -HR modification and filtering
+-demo <- get_nhdplushr(hr_data_dir, layers = "NHDFlowline", min_size_sqkm = 50) plot(st_geometry(demo$NHDFlowline), lwd = demo$NHDFlowline$StreamOrde/4, col = "blue")
@@ -343,7 +363,7 @@++demo <- get_nhdplushr(hr_data_dir, layers = "NHDFlowline", min_size_sqkm = 100, proj = "+init=epsg:5070", simp = 200, keep_cols = c("COMID", "StreamOrde")) #> Warning in CPL_crs_from_input(x): GDAL Message 1: +init=epsg:XXXX syntax is -#> deprecated. It might return a CRS with a non-EPSG compliant axis order. -names(demo$NHDFlowline) -#> [1] "COMID" "StreamOrde" "Shape" -plot(st_geometry(demo$NHDFlowline), +#> deprecated. It might return a CRS with a non-EPSG compliant axis order.
++names(demo$NHDFlowline) +#> [1] "COMID" "StreamOrde" "Shape"
+plot(st_geometry(demo$NHDFlowline), lwd = demo$NHDFlowline$StreamOrde/4, col = "blue")
Make Standalone Basinsmake_standalone()
@@ -427,7 +451,7 @@++demo <- get_nhdplushr(hr_data_dir, layers = "NHDFlowline", min_size_sqkm = 100, check_terminals = FALSE) @@ -361,11 +381,13 @@
Make Standalone Basins print(data.frame(broken_outlet)) #> Hydroseq TerminalPa TerminalFl LevelPathI -#> 1 22001000000414 22000100000212 0 22000300045683 -print(data.frame(fixed_outlet)) +#> 1 22001000000414 22000100000212 0 22000300045683
++print(data.frame(fixed_outlet)) #> Hydroseq TerminalPa TerminalFl LevelPathI -#> 1 22001000000414 22001000000414 1 22001000000414 - +#> 1 22001000000414 22001000000414 1 22001000000414
++(broken <- dplyr::filter(demo$NHDFlowline, TerminalPa == demo_outlet$Hydroseq)) #> Simple feature collection with 0 features and 57 fields #> Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA @@ -377,8 +399,9 @@
Make Standalone Basins#> # MainPath <int>, InNetwork <int>, VisibilityFilter <int>, #> # Shape_Length <dbl>, COMID <dbl>, VPUID <chr>, Enabled <int>, #> # Shape <GEOMETRY [°]>, StreamLeve <int>, StreamOrde <int>, StreamCalc <int>, -#> # FromNode <dbl>, ToNode <dbl>, Hydroseq <dbl>, LevelPathI <dbl>, … -(standalone <- dplyr::filter(standalone_demo, TerminalPa == standalone_demo_outlet$Hydroseq)) +#> # FromNode <dbl>, ToNode <dbl>, Hydroseq <dbl>, LevelPathI <dbl>, …
++(standalone <- dplyr::filter(standalone_demo, TerminalPa == standalone_demo_outlet$Hydroseq)) #> Simple feature collection with 5358 features and 57 fields #> Geometry type: MULTILINESTRING #> Dimension: XY @@ -403,8 +426,9 @@
Make Standalone Basins#> # MainPath <int>, InNetwork <int>, VisibilityFilter <int>, #> # Shape_Length <dbl>, COMID <dbl>, VPUID <chr>, Enabled <int>, #> # Shape <MULTILINESTRING [°]>, StreamLeve <int>, StreamOrde <int>, -#> # StreamCalc <int>, FromNode <dbl>, ToNode <dbl>, Hydroseq <dbl>, … - +#> # StreamCalc <int>, FromNode <dbl>, ToNode <dbl>, Hydroseq <dbl>, …
+plot(st_geometry(standalone))
Make Standalone Basins -
Site built with pkgdown 2.0.7.
+Site built with pkgdown 2.0.9.
The
plot_nhdplus
functionnhdplusTools uses web services to get data and we get a plot like this:+-plot_nhdplus("05428500")
plot_nhdplus("05428500") +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be set
If we want to add other watersheds, we can use any outlet available from the Network Linked Data Index. See “nldi” functions elsewhere in
nhdplusTools
.+ list("huc12pp", "070900020602"))) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be setplot_nhdplus(list(list("nwissite", "USGS-05428500"), - list("huc12pp", "070900020602")))
+ list("huc12pp", "070900020602"))) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be setplot_nhdplus(list(list("nwissite", "USGS-05428500"), - list("huc12pp", "070900020602")))
If we don’t know a site id, we can just pass in one or more latitude / longitude locations.
@@ -152,7 +170,13 @@The
plot_nhdplus
functionstart_point <- sf::st_as_sf(data.frame(x = -89.36, y = 43.09), coords = c("x", "y"), crs = 4326) -plot_nhdplus(start_point)
plot_nhdplus
also allows modification of streamorder (if you have data available locally) and styles. This plot request shows how @@ -170,13 +194,25 @@The
plot_nhdplus
function nhdplus_data = sample_data, plot_config = list(basin = list(lwd = 2), outlets = list(huc12pp = list(cex = 1.5), - comid = list(col = "green"))))We can also plot NHDPlus data without an outlet at all.
+plot_nhdplus(bbox = bbox) +#> Warning in par(old_par): graphical parameter "cin" cannot be set +#> Warning in par(old_par): graphical parameter "cra" cannot be set +#> Warning in par(old_par): graphical parameter "csi" cannot be set +#> Warning in par(old_par): graphical parameter "cxy" cannot be set +#> Warning in par(old_par): graphical parameter "din" cannot be set +#> Warning in par(old_par): graphical parameter "page" cannot be setbbox <- sf::st_bbox(c(xmin = -89.56684, ymin = 42.99816, xmax = -89.24681, ymax = 43.17192), crs = "+proj=longlat +datum=WGS84 +no_defs") -plot_nhdplus(bbox = bbox)
The plots above are all in the EPSG:3857 projection to be compatible with background tiles. Any data added to these plots must be projected @@ -194,7 +230,6 @@
Getting DatadataRetrieval::get_nldi_sources.
+library(sf) -#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE library(nhdplusTools) nwissite <- list(featureSource = "nwissite", featureID = "USGS-05428500") @@ -211,8 +246,9 @@
Getting Data#> Reading NHDFlowline_Network #> Spherical geometry (s2) switched off #> Spherical geometry (s2) switched on -#> Writing NHDFlowline_Network - +#> Writing NHDFlowline_Network
+flowline <- read_sf(nhdplus, "NHDFlowline_Network") upstream_nwis <- navigate_nldi(nwissite, @@ -223,13 +259,14 @@
is an expansion factor. Colors shown below are basic R colors. theGetting Data
++st_layers(nhdplus) #> Driver: GPKG #> Available layers: #> layer_name geometry_type features fields crs_name -#> 1 NHDFlowline_Network Line String 10 137 NAD83 -names(flowline) +#> 1 NHDFlowline_Network Line String 10 137 NAD83
++names(flowline) #> [1] "comid" "fdate" "resolution" "gnis_id" "gnis_name" #> [6] "lengthkm" "reachcode" "flowdir" "wbareacomi" "ftype" #> [11] "fcode" "shape_length" "streamleve" "streamorde" "streamcalc" @@ -257,16 +294,21 @@
Getting Data#> [121] "va_11" "qc_11" "vc_11" "qe_11" "ve_11" #> [126] "qa_12" "va_12" "qc_12" "vc_12" "qe_12" #> [131] "ve_12" "lakefract" "surfarea" "rareahload" "rpuid" -#> [136] "vpuid" "enabled" "geom" -names(upstream_nwis) -#> [1] "origin" "UT_nwissite" -names(basin) -#> [1] "geometry" -class(st_geometry(flowline)) -#> [1] "sfc_LINESTRING" "sfc" -class(st_geometry(upstream_nwis$UT_nwissite)) -#> [1] "sfc_POINT" "sfc" -class(st_geometry(basin)) +#> [136] "vpuid" "enabled" "geom"
++names(upstream_nwis) +#> [1] "origin" "UT_nwissite"
++names(basin) +#> [1] "geometry"
++class(st_geometry(flowline)) +#> [1] "sfc_LINESTRING" "sfc"
++class(st_geometry(upstream_nwis$UT_nwissite)) +#> [1] "sfc_POINT" "sfc"
+class(st_geometry(basin)) #> [1] "sfc_POLYGON" "sfc"
Our file has four layers: network flowlines, simplified catchments, nhd area features, and nhd waterbody features.
@@ -299,7 +341,7 @@Base R Plottingcex
rgb
function is handy for creating colors with transparency if that’s of interest. -@@ -73,7 +73,15 @@+@@ -318,7 +318,7 @@prep_layer <- function(x) st_geometry(st_transform(x, 3857)) bb <- sf::st_as_sfc(sf::st_bbox(prep_layer(basin))) @@ -345,15 +387,16 @@
. Note that ggmap takes case of projections for us, which should either make you happy because it just works or very nervous because it just works. -Plotting with ggplot2geom_sf
@@ -69,7 +69,7 @@ diff --git a/docs/index.html b/docs/index.html index dfac40d8..60afb67c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -12,7 +12,7 @@ - + @@ -40,7 +40,7 @@++library(ggmap) library(ggplot2) ggmap_bbox <- setNames(sf::st_bbox(basin), c("left", "bottom", "right", "top")) ggmap_bbox #> left bottom right top -#> -89.60465 43.03507 -89.20378 43.36607 - +#> -89.60465 43.03507 -89.20378 43.36607
diff --git a/docs/articles/plot_nhdplus_files/figure-html/bbox_plotting-1.png b/docs/articles/plot_nhdplus_files/figure-html/bbox_plotting-1.png index b47131e5..260a8110 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/bbox_plotting-1.png and b/docs/articles/plot_nhdplus_files/figure-html/bbox_plotting-1.png differ diff --git a/docs/articles/plot_nhdplus_files/figure-html/nwis_simple1-1.png b/docs/articles/plot_nhdplus_files/figure-html/nwis_simple1-1.png index 6cada614..9e11b53d 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/nwis_simple1-1.png and b/docs/articles/plot_nhdplus_files/figure-html/nwis_simple1-1.png differ diff --git a/docs/articles/plot_nhdplus_files/figure-html/nwis_simple2-1.png b/docs/articles/plot_nhdplus_files/figure-html/nwis_simple2-1.png index f4d58b85..e740a65c 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/nwis_simple2-1.png and b/docs/articles/plot_nhdplus_files/figure-html/nwis_simple2-1.png differ diff --git a/docs/articles/plot_nhdplus_files/figure-html/plot_styles-1.png b/docs/articles/plot_nhdplus_files/figure-html/plot_styles-1.png index 320c9656..8d18ef63 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/plot_styles-1.png and b/docs/articles/plot_nhdplus_files/figure-html/plot_styles-1.png differ diff --git a/docs/articles/plot_nhdplus_files/figure-html/point_location-1.png b/docs/articles/plot_nhdplus_files/figure-html/point_location-1.png index 6cada614..86636fed 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/point_location-1.png and b/docs/articles/plot_nhdplus_files/figure-html/point_location-1.png differ diff --git a/docs/articles/plot_nhdplus_files/figure-html/two_outlets-1.png b/docs/articles/plot_nhdplus_files/figure-html/two_outlets-1.png index f4d58b85..e740a65c 100644 Binary files a/docs/articles/plot_nhdplus_files/figure-html/two_outlets-1.png and b/docs/articles/plot_nhdplus_files/figure-html/two_outlets-1.png differ diff --git a/docs/authors.html b/docs/authors.html index 3ceff58d..577fc103 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,5 +1,5 @@ -+upstream_nwis <- dplyr::bind_cols(upstream_nwis$UT_nwissite, dplyr::rename(dplyr::as_tibble(sf::st_coordinates(upstream_nwis$UT_nwissite)), lat = Y, lon = X)) @@ -406,7 +449,7 @@
Plotting with ggplot2 -
Site built with pkgdown 2.0.7.
+Site built with pkgdown 2.0.9.
Authors and Citation • nhdplusTools Authors and Citation • nhdplusTools @@ -17,7 +17,7 @@Developers
diff --git a/docs/news/index.html b/docs/news/index.html index d4e05f89..de9ee4c5 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -1,5 +1,5 @@ -Changelog • nhdplusTools Changelog • nhdplusTools @@ -17,7 +17,7 @@Changelog
-+nhdplusTools 1.2.0
+nhdplusTools 1.3.0
+
- Deprecated
+discover_nldi_characteristics()
andget_nldi_characteristics()
+- Bug fix for data cache directory #389
+- Improved warnings for web service requests. #400, #398
+- Improved documentation for
+get_split_catchment()
. #399+nhdplusTools 1.2.02024-05-28
This release introduces a new data source: https://reference.geoconnex.us and a vignette providing a broad overview of data access with nhdplusTools.
- Fixed bug with use of memoise cache #365
- Added
@@ -233,13 +241,13 @@vignette("get_data_overview")
for WaterSciCon24Web Service Wrapper Functions
Utility Functions
-
- +
New functions
st_compatibalize()
andrename_geometry()
provide utility functionality to make two layers compatible, including projection and rename geometry columns respectively.
New functions
st_compatibalize()
andrename_geometry()
provide utility functionality to make two layers compatible, including projection and rename geometry columns respectively.New function
get_sorted()
generates a sorted and optionally partitioned version of a dendritic tree.@@ -248,7 +256,7 @@Subsetting and data utilities
- New function
-subset_vpu()
wrapssubset_rpu()
and will subset a vector processing unit.- New function
+fix_flowdir()
will re-order geometry nodes such that their order corresponds to the convention used in nhdplus data.- New function
fix_flowdir()
will re-order geometry nodes such that their order corresponds to the convention used in nhdplus data.get_vaa()
will now return an updated nhdplus network attribute set derived from multiple improved sources.Network Navigation and Attribut
- New function
navigate_network()
provides a wrapper around a number of network navigation capabilities and will support local or web service data.- New function
get_tocomid()
encapsulates a suite of functionality for converting edge node network representations to edge list format.- New function
-get_path_lengths()
finds network distances between pairs of points.- New function
+get_partial_length()
finds flowpath length up and downstream of a hydrologic location.- New function
get_partial_length()
finds flowpath length up and downstream of a hydrologic location.Plotting
@@ -277,7 +285,7 @@nhdplusTools
Version 0.4.2 further cleans up temporary and cache data functionality for CRAN policy.
New functionality was added to indexing functionality.
- When multiple flowlines are returned,
-disambiguate_flowline_indexes()
supports for disambiguating them based on numeric or text attributes that should match. This functionality is not heavily tested, but forms a basis for expansion of this functionality going forward.- A function to find the point location of a flowline index,
+get_hydro_location()
was added. It will return point geometry given a geometry identifier and measure along that identifier.- A function to find the point location of a flowline index,
get_hydro_location()
was added. It will return point geometry given a geometry identifier and measure along that identifier.nhdplusTools 0.3.142020-08-03
-
- Added
+get_node()
to get top and bottom of a flowline.
- Added
get_node()
to get top and bottom of a flowline.- Switched geospatial data dependency to use labs.waterdata.usgs.gov
- Added
subset_rpu()
to enable subsetting the NHD by Raster Processing Unit- Added
@@ -382,7 +390,7 @@get_waterbody_index()
to find associations between point locations and waterbodies.nhdplusTools
Add NHDPlus Network Attributes to a provided network. — add_plus_network_attributes • nhdplusTools Add NHDPlus Network Attributes to a provided network. — add_plus_network_attributes • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0Examples
add_plus_network_attributes(test_flowline) #> Loading required namespace: future #> Loading required namespace: future.apply -#> # A tibble: 62 × 14 -#> comid tocomid nameID lengthkm areasqkm weight terminalpa hydroseq levelpathi -#> <int> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 5.33e6 0 255208 1.20 0.868 137. 1 1 1 -#> 2 5.33e6 5329303 255208 0.582 0.260 133. 1 3 1 -#> 3 5.33e6 5329293 255208 4.02 3.76 127. 1 5 1 -#> 4 5.33e6 5329305 255208 4.44 4.51 120. 1 8 1 -#> 5 5.33e6 5329317 255208 2.68 3.64 112. 1 10 1 -#> 6 5.33e6 5329315 255208 4.79 5.96 75.3 1 27 1 -#> 7 5.33e6 5329339 255208 1.03 1.27 67.4 1 29 1 -#> 8 5.33e6 5329343 255208 3.60 6.94 61.9 1 31 1 -#> 9 5.33e6 5329357 255208 3.14 5.13 51.1 1 37 1 -#> 10 5.33e6 5329365 254577 1.46 1.69 37.8 1 42 1 -#> # ℹ 52 more rows -#> # ℹ 5 more variables: pathlength <dbl>, dnlevelpat <dbl>, dnhydroseq <dbl>, -#> # totdasqkm <dbl>, terminalfl <dbl> +#> Warning: Unknown or uninitialised column: `lengthkm`. +#> Error in pathlength_km[i] <- length_km[toids[i]] + pathlength_km[toids[i]]: replacement has length zeroExamples
Align NHD Dataset Names — align_nhdplus_names • nhdplusTools Align NHD Dataset Names — align_nhdplus_names • nhdplusTools @@ -17,7 +17,7 @@Examples
Calculate Arbolate Sum — calculate_arbolate_sum • nhdplusTools Calculate Arbolate Sum — calculate_arbolate_sum • nhdplusTools Total Drainage Area — calculate_total_drainage_area • nhdplusTools Total Drainage Area — calculate_total_drainage_area • nhdplusTools Disambiguate Flowline Indexes — disambiguate_flowline_indexes • nhdplusTools Disambiguate Flowline Indexes — disambiguate_flowline_indexes • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0Examples
discover geoconnex reference feature layers — discover_geoconnex_reference • nhdplusTools discover geoconnex reference feature layers — discover_geoconnex_reference • nhdplusTools Discover NHDPlus ID — discover_nhdplus_id • nhdplusTools Discover NHDPlus ID — discover_nhdplus_id • nhdplusTools @@ -17,7 +17,7 @@Examples
Discover Characteristics Metadata — discover_nldi_characteristics • nhdplusTools (DEPRECATED) Discover Characteristics Metadata — discover_nldi_characteristics • nhdplusTools @@ -17,7 +18,7 @@diff --git a/docs/reference/download_nhd.html b/docs/reference/download_nhd.html index 763c9e34..ef989a4a 100644 --- a/docs/reference/download_nhd.html +++ b/docs/reference/download_nhd.html @@ -1,5 +1,5 @@ --Discover Characteristics Metadata
+(DEPRECATED) Discover Characteristics Metadata
Source:R/get_nldi.R
discover_nldi_characteristics.Rd
-Provides access to metadata for characteristics that are returned by `get_nldi_characteristics()`.
+This functionality is deprecated and will be removed in the near future.
+Please use get_characteristics_metadata instead.
@@ -94,102 +96,6 @@-Value
data.frame containing available characteristics
-Examples
--chars <- discover_nldi_characteristics() -names(chars) -#> [1] "local" "total" "divergence_routed" -head(chars$local, 10) -#> characteristic_id -#> 1 CAT_WILDFIRE_2011 -#> 2 CAT_CONTACT -#> 3 CAT_EWT -#> 4 CAT_FUNGICIDE -#> 5 CAT_IEOF -#> 6 CAT_PET -#> 7 CAT_RECHG -#> 8 CAT_SATOF -#> 9 CAT_TWI -#> 10 CAT_WB5100_ANN -#> characteristic_description -#> 1 percent of wild fires per catchments for 2011 -#> 2 Subsurface flow contact time index. The subsurface contact time index estimates the number of days that infiltrated water resides in the saturated subsurface zone of the basin before discharging into the stream. -#> 3 Average depth to water table relatice to the land surface(meters) -#> 4 Fungicide use on agricultural land in kilograms per square kilometer, 2009 per NHDPlus version 2 catchment -#> 5 Percentage of Horton overland flow as a percent -#> 6 Mean-annual potential evapotranspiration (PET), estimated using the Hamon (1961) equation. -#> 7 Mean annual natural ground-water recharge in millimeters per year -#> 8 Percentage of Dunne overland flow as a percent -#> 9 Topographic wetness index, ln(a/S); where ln is the natural log, a is the upslope area per unit contour length and S is the slope at that point. See http://ks.water.usgs.gov/Kansas/pubs/reports/wrir.99-4242.html and Wolock and McCabe, 1995 for more detail -#> 10 Average annual runoff (mm) from McCabe and Wolock's Runoff Model 1951-2000 per NHDPlus version 2 catchment -#> units -#> 1 percent -#> 2 days -#> 3 meters -#> 4 kilogram per square kilometer -#> 5 percent -#> 6 mm/year -#> 7 mm/yr -#> 8 percent -#> 9 ln(m) -#> 10 millimeters per year -#> dataset_label -#> 1 Estimated percent of catchment that experienced a wild fire in year XXXX. -#> 2 Contact time, the length of time it takes for water to drain along subsurface flow paths to the stream, per NHDPlus version 2 catchment. -#> 3 Average depth to water table relative to land surface per NHDPlus version 2 catchment -#> 4 Fungicide use on agricultural land in kilograms per square kilometer, 2009 per NHDPlus version 2 catchment -#> 5 Mean infiltration-excess overland flow as a percent of streamflow per NHDPlus version 2 catchment -#> 6 PRISM 30-year average Potential Evapotranspiration, 1971-2000 per NHDPlus version 2 catchment -#> 7 Estimated 30 year (1951-1980) mean annual natural groundwater recharge per NHDPlus version 2 catchment. -9999 denotes source data does not cover catchment. -#> 8 Mean saturation overland flow as a percent of streamflow per NHDPlus version 2 catchment. -9999 denotes NODATA or flowline has no catchment. -9999 denotes flowline reach has no catchment. -#> 9 average topgraphic wetness index per NHDPlus version 2 catchment -#> 10 Average annual runoff (mm) from McCabe and Wolock's Runoff Model 1951-2000 per NHDPlus version 2 catchment -#> dataset_url -#> 1 https://www.sciencebase.gov/catalog/item/57f66d66e4b0bc0bec06de3a -#> 2 https://www.sciencebase.gov/catalog/item/56f96fc5e4b0a6037df06b12 -#> 3 https://www.sciencebase.gov/catalog/item/56f97456e4b0a6037df06b50 -#> 4 https://www.sciencebase.gov/catalog/item/56fd610fe4b022712b81bf9f -#> 5 https://www.sciencebase.gov/catalog/item/56f974e2e4b0a6037df06b55 -#> 6 https://www.sciencebase.gov/catalog/item/56f96ed1e4b0a6037df06a2d -#> 7 https://www.sciencebase.gov/catalog/item/56f97577e4b0a6037df06b5a -#> 8 https://www.sciencebase.gov/catalog/item/56f97acbe4b0a6037df06b6a -#> 9 https://www.sciencebase.gov/catalog/item/56f97be4e4b0a6037df06b70 -#> 10 https://www.sciencebase.gov/catalog/item/56fd5bd0e4b0c07cbfa40473 -#> theme_label -#> 1 Land Cover -#> 2 Hydrologic -#> 3 Hydrologic -#> 4 Chemical -#> 5 Hydrologic -#> 6 Climate -#> 7 Hydrologic -#> 8 Hydrologic -#> 9 Hydrologic -#> 10 Hydrologic -#> theme_url -#> 1 unknown -#> 2 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 3 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 4 https://www.sciencebase.gov/catalog/item/56fd600fe4b022712b81bf9a -#> 5 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 6 https://www.sciencebase.gov/catalog/item/566ef828e4b09cfe53ca76f7 -#> 7 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 8 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 9 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> 10 https://www.sciencebase.gov/catalog/item/5669a8a4e4b08895842a1d4c -#> characteristic_type -#> 1 localCatch_name -#> 2 localCatch_name -#> 3 localCatch_name -#> 4 localCatch_name -#> 5 localCatch_name -#> 6 localCatch_name -#> 7 localCatch_name -#> 8 localCatch_name -#> 9 localCatch_name -#> 10 localCatch_name -
Download NHD — download_nhd • nhdplusTools Download NHD — download_nhd • nhdplusTools @@ -17,7 +17,7 @@Examples
Download NHDPlus HiRes — download_nhdplushr • nhdplusTools Download NHDPlus HiRes — download_nhdplushr • nhdplusTools @@ -17,7 +17,7 @@Download NHDPlus HiRes
-+download_nhdplushr(nhd_dir, hu_list, download_files = TRUE)
download_nhdplushr(nhd_dir, hu_list, download_files = TRUE, archive = FALSE)
@@ -97,6 +97,14 @@Arguments
+ + boolean if FALSE, only URLs to files will be returned can be hu02s and/or hu04s
archive ++ pull data from the "archive" folder rather than "current". +The archive contains the original releases of NHDPlusHR data that were updated +in subsequent processing. Not all subsets of NHDPlusHR were updated. See: +https://www.usgs.gov/national-hydrography/access-national-hydrography-products +for more details.
Value
@@ -126,6 +134,19 @@Examples
#> [9] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0109_HU4_20230713_GDB.zip" #> [10] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0110_HU4_20220323_GDB.zip" #> [11] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Current/GDB/NHDPLUS_H_0203_HU4_20220323_GDB.zip" + +download_nhdplushr(tempdir(), c(hu, "0203"), download_files = FALSE, archive = TRUE) +#> [1] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0101_HU4_GDB.zip" +#> [2] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0102_HU4_GDB.zip" +#> [3] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0103_HU4_GDB.zip" +#> [4] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0104_HU4_GDB.zip" +#> [5] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0105_HU4_GDB.zip" +#> [6] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0106_HU4_GDB.zip" +#> [7] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0107_HU4_GDB.zip" +#> [8] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0108_HU4_GDB.zip" +#> [9] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0109_HU4_GDB.zip" +#> [10] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0110_HU4_GDB.zip" +#> [11] "https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHDPlusHR/VPU/Archive/GDB/NHDPLUS_H_0203_HU4_GDB.zip" # }Examples
Download seamless National Hydrography Dataset Version 2 (NHDPlusV2) — download_nhdplusv2 • nhdplusTools Download seamless National Hydrography Dataset Version 2 (NHDPlusV2) — download_nhdplusv2 • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0Examples
Download the seamless Reach File (RF1) Database — download_rf1 • nhdplusTools Download the seamless Reach File (RF1) Database — download_rf1 • nhdplusTools Download NHDPlusVAA data from HydroShare — download_vaa • nhdplusTools Download NHDPlusVAA data from HydroShare — download_vaa • nhdplusTools @@ -17,7 +17,7 @@Details
Download the seamless Watershed Boundary Dataset (WBD) — download_wbd • nhdplusTools Download the seamless Watershed Boundary Dataset (WBD) — download_wbd • nhdplusTools Get 3DHP Data — get_3dhp • nhdplusTools Get 3DHP Data — get_3dhp • nhdplusTools Navigate Downstream with Diversions — get_DD • nhdplusTools Navigate Downstream with Diversions — get_DD • nhdplusTools Navigate Downstream Mainstem — get_DM • nhdplusTools Navigate Downstream Mainstem — get_DM • nhdplusTools @@ -17,7 +17,7 @@Examples
Navigate Upstream Mainstem — get_UM • nhdplusTools Navigate Upstream Mainstem — get_UM • nhdplusTools @@ -17,7 +17,7 @@Examples
Navigate Upstream with Tributaries — get_UT • nhdplusTools Navigate Upstream with Tributaries — get_UT • nhdplusTools @@ -17,7 +17,7 @@Examples
Return RPU or VPU boundaries — get_boundaries • nhdplusTools Return RPU or VPU boundaries — get_boundaries • nhdplusTools @@ -17,7 +17,7 @@Value
Get Catchment Characteristics — get_catchment_characteristics • nhdplusTools Get Catchment Characteristics — get_catchment_characteristics • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0Examples
Get catchment characteristics metadata table — get_characteristics_metadata • nhdplusTools Get catchment characteristics metadata table — get_characteristics_metadata • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0Examples
Get Elevation Along Path (experimental) — get_elev_along_path • nhdplusTools Get Elevation Along Path (experimental) — get_elev_along_path • nhdplusTools Get Flowline Index — get_flowline_index • nhdplusTools Get Flowline Index — get_flowline_index • nhdplusTools Find gagesII Features — get_gagesII • nhdplusTools Find gagesII Features — get_gagesII • nhdplusTools get geoconnex reference feature layers — get_geoconnex_reference • nhdplusTools get geoconnex reference feature layers — get_geoconnex_reference • nhdplusTools @@ -17,7 +17,7 @@ @@ -159,10 +159,10 @@Examples
#> Bounding box: xmin: -91.15213 ymin: 41.22784 xmax: -88.18307 ymax: 46.21648 #> Geodetic CRS: WGS 84 #> # A tibble: 2 × 8 -#> id fid gnis_id loaddate name uri gnis_url -#> * <chr> <int> <chr> <dttm> <chr> <chr> <chr> -#> 1 0707 189 NA 2017-02-01 00:53:08 Wisconsin https://geoconnex.… "" -#> 2 0709 65 NA 2012-06-11 07:54:59 Rock https://geoconnex.… "" +#> id loaddate gnis_id gnis_url uri fid name +#> * <chr> <dttm> <chr> <chr> <chr> <int> <chr> +#> 1 0707 2017-02-01 00:53:08 NA "" https://geoconnex.us/r… 189 Wisc… +#> 2 0709 2012-06-11 07:54:59 NA "" https://geoconnex.us/r… 65 Rock #> # ℹ 1 more variable: geometry <MULTIPOLYGON [°]> get_geoconnex_reference("https://geoconnex.us/ref/mainstems/315626", type = "hu04", ) @@ -173,23 +173,23 @@Examples
#> Bounding box: xmin: -106.7484 ymin: 30.05369 xmax: -91.8491 ymax: 39.38306 #> Geodetic CRS: WGS 84 #> # A tibble: 15 × 8 -#> id uri name gnis_id loaddate gnis_url fid -#> * <chr> <chr> <chr> <chr> <dttm> <chr> <int> -#> 1 1102 https://geoconnex.us/… Uppe… NA 2017-04-17 09:39:52 "" 29 -#> 2 1103 https://geoconnex.us/… Midd… NA 2012-06-11 07:54:59 "" 70 -#> 3 1104 https://geoconnex.us/… Uppe… NA 2012-06-11 07:54:59 "" 133 -#> 4 1105 https://geoconnex.us/… Lowe… NA 2012-06-11 07:54:59 "" 143 -#> 5 1106 https://geoconnex.us/… Arka… NA 2017-04-21 13:34:18 "" 144 -#> 6 1107 https://geoconnex.us/… Neos… NA 2017-04-21 13:34:23 "" 145 -#> 7 1108 https://geoconnex.us/… Uppe… NA 2017-09-20 20:59:45 "" 126 -#> 8 1109 https://geoconnex.us/… Lowe… NA 2017-04-24 11:26:44 "" 148 -#> 9 1110 https://geoconnex.us/… Nort… NA 2017-04-21 13:15:51 "" 146 -#> 10 1111 https://geoconnex.us/… Lowe… NA 2017-04-21 13:15:55 "" 7 -#> 11 1112 https://geoconnex.us/… Red … NA 2017-04-24 08:53:22 "" 147 -#> 12 1113 https://geoconnex.us/… Red-… NA 2017-04-24 08:53:22 "" 179 -#> 13 1114 https://geoconnex.us/… Red-… NA 2017-10-15 23:35:54 "" 175 -#> 14 1305 https://geoconnex.us/… Rio … NA 2017-11-05 19:43:51 "" 178 -#> 15 1306 https://geoconnex.us/… Uppe… NA 2017-09-20 20:59:52 "" 129 +#> id loaddate gnis_id gnis_url uri fid name +#> * <chr> <dttm> <chr> <chr> <chr> <int> <chr> +#> 1 1102 2017-04-17 09:39:52 NA "" https://geoconnex.us/… 29 Uppe… +#> 2 1103 2012-06-11 07:54:59 NA "" https://geoconnex.us/… 70 Midd… +#> 3 1104 2012-06-11 07:54:59 NA "" https://geoconnex.us/… 133 Uppe… +#> 4 1105 2012-06-11 07:54:59 NA "" https://geoconnex.us/… 143 Lowe… +#> 5 1106 2017-04-21 13:34:18 NA "" https://geoconnex.us/… 144 Arka… +#> 6 1107 2017-04-21 13:34:23 NA "" https://geoconnex.us/… 145 Neos… +#> 7 1108 2017-09-20 20:59:45 NA "" https://geoconnex.us/… 126 Uppe… +#> 8 1109 2017-04-24 11:26:44 NA "" https://geoconnex.us/… 148 Lowe… +#> 9 1110 2017-04-21 13:15:51 NA "" https://geoconnex.us/… 146 Nort… +#> 10 1111 2017-04-21 13:15:55 NA "" https://geoconnex.us/… 7 Lowe… +#> 11 1112 2017-04-24 08:53:22 NA "" https://geoconnex.us/… 147 Red … +#> 12 1113 2017-04-24 08:53:22 NA "" https://geoconnex.us/… 179 Red-… +#> 13 1114 2017-10-15 23:35:54 NA "" https://geoconnex.us/… 175 Red-… +#> 14 1305 2017-11-05 19:43:51 NA "" https://geoconnex.us/… 178 Rio … +#> 15 1306 2017-09-20 20:59:52 NA "" https://geoconnex.us/… 129 Uppe… #> # ℹ 1 more variable: geometry <MULTIPOLYGON [°]> AOI <- sf::st_sfc(sf::st_point(c(-89.56684, 42.99816)), @@ -203,10 +203,10 @@Examples
#> Bounding box: xmin: -91.15213 ymin: 41.22784 xmax: -88.18307 ymax: 46.21648 #> Geodetic CRS: WGS 84 #> # A tibble: 2 × 8 -#> id fid gnis_id loaddate name uri gnis_url -#> * <chr> <int> <chr> <dttm> <chr> <chr> <chr> -#> 1 0707 189 NA 2017-02-01 00:53:08 Wisconsin https://geoconnex.… "" -#> 2 0709 65 NA 2012-06-11 07:54:59 Rock https://geoconnex.… "" +#> id loaddate gnis_id gnis_url uri fid name +#> * <chr> <dttm> <chr> <chr> <chr> <int> <chr> +#> 1 0707 2017-02-01 00:53:08 NA "" https://geoconnex.us/r… 189 Wisc… +#> 2 0709 2012-06-11 07:54:59 NA "" https://geoconnex.us/r… 65 Rock #> # ℹ 1 more variable: geometry <MULTIPOLYGON [°]> # } @@ -224,7 +224,7 @@Examples
diff --git a/docs/reference/get_hr_data.html b/docs/reference/get_hr_data.html index 974aa111..267924b7 100644 --- a/docs/reference/get_hr_data.html +++ b/docs/reference/get_hr_data.html @@ -1,5 +1,5 @@ -Get NHDPlus HiRes Data — get_hr_data • nhdplusTools Get NHDPlus HiRes Data — get_hr_data • nhdplusTools Find WBD HUC unit subsets — get_huc • nhdplusTools Find WBD HUC unit subsets — get_huc • nhdplusTools Get Level Paths (DEPRECATED) — get_levelpaths • nhdplusTools Get Level Paths (DEPRECATED) — get_levelpaths • nhdplusTools nhdplusTools - 1.2.0 + 1.3.0 @@ -226,7 +226,7 @@Examples
diff --git a/docs/reference/get_nhdarea.html b/docs/reference/get_nhdarea.html index 897632b9..a4c16e87 100644 --- a/docs/reference/get_nhdarea.html +++ b/docs/reference/get_nhdarea.html @@ -1,5 +1,5 @@ -Find NHDPlusV2 Areas — get_nhdarea • nhdplusTools Find NHDPlusV2 Areas — get_nhdarea • nhdplusTools Get National Hydrography Dataset V2 Subsets (Multirealization) — get_nhdplus • nhdplusTools Get National Hydrography Dataset V2 Subsets (Multirealization) — get_nhdplus • nhdplusTools Get NHDPlus HiRes — get_nhdplushr • nhdplusTools Get NHDPlus HiRes — get_nhdplushr • nhdplusTools @@ -17,7 +17,7 @@ @@ -189,7 +189,7 @@Examples
diff --git a/docs/reference/get_nldi_basin-2.png b/docs/reference/get_nldi_basin-2.png index ffd499e7..bc876c79 100644 Binary files a/docs/reference/get_nldi_basin-2.png and b/docs/reference/get_nldi_basin-2.png differ diff --git a/docs/reference/get_nldi_basin.html b/docs/reference/get_nldi_basin.html index e017f16f..56f37059 100644 --- a/docs/reference/get_nldi_basin.html +++ b/docs/reference/get_nldi_basin.html @@ -1,5 +1,5 @@ -Get NLDI Basin Boundary — get_nldi_basin • nhdplusTools Get NLDI Basin Boundary — get_nldi_basin • nhdplusTools @@ -17,7 +17,7 @@ @@ -171,7 +171,7 @@Examples
diff --git a/docs/reference/get_nldi_characteristics.html b/docs/reference/get_nldi_characteristics.html index cade53ee..eead07fd 100644 --- a/docs/reference/get_nldi_characteristics.html +++ b/docs/reference/get_nldi_characteristics.html @@ -1,6 +1,6 @@ -Get Catchment Characteristics — get_nldi_characteristics • nhdplusTools (DEPRECATED) Get Catchment Characteristics — get_nldi_characteristics • nhdplusTools @@ -18,7 +18,7 @@ @@ -69,14 +69,14 @@diff --git a/docs/reference/get_nldi_feature.html b/docs/reference/get_nldi_feature.html index 4173d60f..aee5bcf3 100644 --- a/docs/reference/get_nldi_feature.html +++ b/docs/reference/get_nldi_feature.html @@ -1,5 +1,5 @@ --Get Catchment Characteristics
+(DEPRECATED) Get Catchment Characteristics
Source:R/get_nldi.R
get_nldi_characteristics.Rd
-Retrieves catchment characteristics from the Network Linked Data Index. -Metadata for these characteristics can be found using `discover_nldi_characteristics()`.
+This functionality id deprecated and will be removed in the near future.
+Please use get_catchment_characteristics instead.
@@ -103,27 +103,6 @@-Value
data.frame containing requested characteristics
-Examples
--# \donttest{ -chars <- get_nldi_characteristics(list(featureSource = "nwissite", featureID = "USGS-05429700")) -names(chars) -#> [1] "local" -head(chars$local, 10) -#> characteristic_id characteristic_value percent_nodata -#> 1 CAT_WILDFIRE_2011 0 100 -#> 2 CAT_CONTACT 47.28 0 -#> 3 CAT_EWT -18.74 0 -#> 4 CAT_FUNGICIDE 1.25 0 -#> 5 CAT_IEOF 2 0 -#> 6 CAT_PET 644.71 0 -#> 7 CAT_RECHG 133.18 0 -#> 8 CAT_SATOF 2 0 -#> 9 CAT_TWI 14.05 0 -#> 10 CAT_WB5100_ANN 215.97 0 -# } -
Get NLDI Feature — get_nldi_feature • nhdplusTools Get NLDI Feature — get_nldi_feature • nhdplusTools @@ -17,7 +17,7 @@ @@ -126,7 +126,7 @@Examples
diff --git a/docs/reference/get_nldi_index-1.png b/docs/reference/get_nldi_index-1.png index 1bd983c9..4e8930c3 100644 Binary files a/docs/reference/get_nldi_index-1.png and b/docs/reference/get_nldi_index-1.png differ diff --git a/docs/reference/get_nldi_index.html b/docs/reference/get_nldi_index.html index 13a51891..067a785b 100644 --- a/docs/reference/get_nldi_index.html +++ b/docs/reference/get_nldi_index.html @@ -1,5 +1,5 @@ -Get NLDI Index — get_nldi_index • nhdplusTools Get NLDI Index — get_nldi_index • nhdplusTools Discover USGS NWIS Stream Gages — get_nwis • nhdplusTools Discover USGS NWIS Stream Gages — get_nwis • nhdplusTools Get Path Lengths (DEPRECATED) — get_path_lengths • nhdplusTools Get Path Lengths (DEPRECATED) — get_path_lengths • nhdplusTools Get Path Members (DEPRECATED) — get_path_members • nhdplusTools Get Path Members (DEPRECATED) — get_path_members • nhdplusTools Get Path Length — get_pathlength • nhdplusTools Get Path Length — get_pathlength • nhdplusTools @@ -17,7 +17,7 @@ @@ -106,69 +106,8 @@Examples
#> and networks with drainage area less than 0 sqkm, and drainage basins smaller than 0 get_pathlength(fl) -#> ID pathlength -#> 1 5329303 0.000 -#> 2 5329293 1.195 -#> 3 5329305 1.777 -#> 4 5329317 5.797 -#> 5 5329315 10.240 -#> 6 5329339 12.924 -#> 7 5329343 17.710 -#> 8 5329357 18.742 -#> 9 5329365 22.345 -#> 10 5329373 25.484 -#> 11 5329385 28.463 -#> 12 5329821 30.379 -#> 13 5329395 31.511 -#> 14 5329397 33.519 -#> 15 5329389 34.700 -#> 16 5329435 35.130 -#> 17 5329313 12.924 -#> 18 5329311 14.870 -#> 19 5329817 16.043 -#> 20 5329323 20.855 -#> 21 5329325 21.822 -#> 22 5329327 21.496 -#> 23 5329347 22.473 -#> 24 5329291 1.777 -#> 25 5329363 25.484 -#> 26 5329819 26.764 -#> 27 5329359 29.649 -#> 28 5329333 10.240 -#> 29 5329371 18.742 -#> 30 5329375 22.345 -#> 31 5329377 24.666 -#> 32 5329379 24.666 -#> 33 5329399 24.748 -#> 34 5329405 24.748 -#> 35 5329427 30.379 -#> 36 5329413 31.511 -#> 37 5329419 33.519 -#> 38 5329391 35.130 -#> 39 5329407 35.306 -#> 40 5329387 34.700 -#> 41 5329415 27.521 -#> 42 5329355 29.649 -#> 43 5329337 17.710 -#> 44 5329335 21.496 -#> 45 5329345 22.878 -#> 46 5329341 22.878 -#> 47 5329321 22.473 -#> 48 5329841 23.494 -#> 49 5329815 27.094 -#> 50 5329319 20.855 -#> 51 5329309 16.043 -#> 52 5329307 14.870 -#> 53 5329299 5.797 -#> 54 5329297 7.206 -#> 55 5329295 1.195 -#> 56 5329849 35.779 -#> 57 5329393 35.306 -#> 58 5329871 38.554 -#> 59 5329383 36.172 -#> 60 5329847 27.173 -#> 61 5329845 27.173 -#> 62 5329843 26.943 +#> Warning: Unknown or uninitialised column: `lengthkm`. +#> Error in pathlength_km[i] <- length_km[toids[i]] + pathlength_km[toids[i]]: replacement has length zero
RPU Boundaries -Raster Processing Unit boundaries
RPU Boundaries Raster Processing Unit boundaries
VPU Boundaries -Vector Processing Unit boundaries
VPU Boundaries Vector Processing Unit boundaries
Discover Characteristics Metadata
(DEPRECATED) Discover Characteristics Metadata
Get Catchment Characteristics
(DEPRECATED) Get Catchment Characteristics
These objects are imported from other packages. Follow the links below to see their documentation.
fix_flowdir
, get_hydro_location
, get_node
, get_partial_length
, rename_geometry
, rescale_measures
, st_compatibalize
fix_flowdir
, get_hydro_location
, get_node
, get_partial_length
, rename_geometry
, rescale_measures
, st_compatibalize
R/rescale_catchments.R
- rescale_catchment_characteristics.Rd
Given catchment characteristics to retrieve or process will -aggregate and / or split the characteristics according to a lookup table.
-rescale_catchment_characteristics(
- vars,
- lookup_table,
- refactored_areas = NULL,
- catchment_characteristics = NULL,
- catchment_areas = NULL
-)
data.frame containing `characteristic_id` retrieved from -get_characteristics_metadata and `summary_statistic` indicating -which summary statistic should be applied to rescale each characteristic. -Accepted values are "sum," "length_weighted_mean," "area_weighted_mean," -"min," and "max."
data.frame containing `id` numeric vector of identifiers -at the desired scale; "comid" is a numeric vector of NHDPlusV2 identifiers; -"member_comid" contains formatted NHDPlusV2 COMIDs indicating that the -catchments in question need to be split. If catchments have not been split, -the columns "comid" and "member_comid" should be identical.
data.frame containing columns "featureid" and "areasqkm." -Used to retrieve adjusted catchment areas in the case of split catchments. If -not provided, either no split catchments can be considered or the `catchment_areas` -parameter is required.
data.frame containing columns -"characteristic_id", "comid", "characteristic_value", and "percent_nodata". -If not provided, it will be retrieved from get_catchment_characteristics -using the characteristic ids from `vars` and the comids from `lookup_table`.
data.frame containing columns "comid", "areasqkm", -"split_catchment_areasqkm", and "split_area_prop". If not provided, it will -be retrieved from `refactored_areas` and/or get_vaa.
NOTE: Since this algorithm works on catchment characteristics that are -spatial averages, when splitting, the average condition is apportioned evenly -to each split. In some cases, such as with land cover or elevation, this may -not be appropriate and source data should be used to derive new characteristics. -In addition, this function handles catchment areas for split catchments but -makes no adjustments for the length of flowlines in those catchments. -Therefore, requests for length-weighted mean values may not be appropriate -when working with split catchments.
-# \donttest{
-vars <- data.frame(characteristic_id = c("CAT_IMPV11","CAT_BASIN_AREA"),
- summary_statistic = c("area_weighted_mean","sum"))
-lookup_table <- data.frame(id = rep(10012268, 2),
- comid = c(4146596, 4147382),
- member_comid = c(4146596, 4147382))
-rescale_catchment_characteristics(vars, lookup_table)
-#> didn't find data, downloading.
-#>
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========= | 14%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================ | 24%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================= | 34%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================ | 64%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================= | 94%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
-#> # A tibble: 1 × 6
-#> id areasqkm_sum lengthkm_sum CAT_IMPV11_area_wtd percent_nodata_CAT_BA…¹
-#> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 10012268 12.9 6.30 0 0
-#> # ℹ abbreviated name: ¹percent_nodata_CAT_BASIN_AREA_area_wtd
-#> # ℹ 1 more variable: CAT_BASIN_AREA_sum <dbl>
-
-vars <- data.frame(characteristic_id = c("CAT_ELEV_MIN","CAT_ELEV_MAX"),
- summary_statistic = c("min","max"))
-lookup_table <- data.frame(id = rep(10012268, 2),
- comid = c(4146596, 4147382),
- member_comid = c(4146596, 4147382))
-rescale_catchment_characteristics(vars, lookup_table)
-#> # A tibble: 1 × 7
-#> id areasqkm_sum lengthkm_sum percent_nodata_CAT_E…¹ percent_nodata_CAT_E…²
-#> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 1.00e7 12.9 6.30 0 0
-#> # ℹ abbreviated names: ¹percent_nodata_CAT_ELEV_MIN_area_wtd,
-#> # ²percent_nodata_CAT_ELEV_MAX_area_wtd
-#> # ℹ 2 more variables: CAT_ELEV_MIN_min <dbl>, CAT_ELEV_MAX_max <dbl>
-
-vars <- data.frame(characteristic_id = c("CAT_EWT","CAT_TWI", "CAT_BASIN_AREA"),
- summary_statistic = c("area_weighted_mean", "area_weighted_mean","sum"))
-lookup_table <- data.frame(id = c(10012268, 10012268, 10024047, 10024048),
- comid = c(4146596, 4147382, 4147396, 4147396),
- member_comid = c("4146596", "4147382", "4147396.1", "4147396.2"))
-comid_areas <- data.frame(featureid = c("4146596", "4147382", "4147396.1", "4147396.2"),
- areasqkm = c(0.9558, 11.9790, 6.513294, 1.439999))
-rescale_catchment_characteristics(vars, lookup_table, refactored_areas = comid_areas)
-#> # A tibble: 3 × 9
-#> id areasqkm_sum lengthkm_sum CAT_EWT_area_wtd CAT_TWI_area_wtd
-#> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 10012268 12.9 6.30 -25.5 9.59
-#> 2 10024047 6.51 4.31 -24.6 9.07
-#> 3 10024048 1.44 4.31 -5.44 2.00
-#> # ℹ 4 more variables: percent_nodata_CAT_EWT_area_wtd <dbl>,
-#> # percent_nodata_CAT_TWI_area_wtd <dbl>,
-#> # percent_nodata_CAT_BASIN_AREA_area_wtd <dbl>, CAT_BASIN_AREA_sum <dbl>
-
- # }
-
-
R/rescale_catchments.R
+ rescale_catchment_characteristics.Rd
Given catchment characteristics to retrieve or process will +aggregate and / or split the characteristics according to a lookup table.
+rescale_catchment_characteristics(
+ vars,
+ lookup_table,
+ refactored_areas = NULL,
+ catchment_characteristics = NULL,
+ catchment_areas = NULL
+)
data.frame containing `characteristic_id` retrieved from +get_characteristics_metadata and `summary_statistic` indicating +which summary statistic should be applied to rescale each characteristic. +Accepted values are "sum," "length_weighted_mean," "area_weighted_mean," +"min," and "max."
data.frame containing `id` numeric vector of identifiers +at the desired scale; "comid" is a numeric vector of NHDPlusV2 identifiers; +"member_comid" contains formatted NHDPlusV2 COMIDs indicating that the +catchments in question need to be split. If catchments have not been split, +the columns "comid" and "member_comid" should be identical.
data.frame containing columns "featureid" and "areasqkm." +Used to retrieve adjusted catchment areas in the case of split catchments. If +not provided, either no split catchments can be considered or the `catchment_areas` +parameter is required.
data.frame containing columns +"characteristic_id", "comid", "characteristic_value", and "percent_nodata". +If not provided, it will be retrieved from get_catchment_characteristics +using the characteristic ids from `vars` and the comids from `lookup_table`.
data.frame containing columns "comid", "areasqkm", +"split_catchment_areasqkm", and "split_area_prop". If not provided, it will +be retrieved from `refactored_areas` and/or get_vaa.
NOTE: Since this algorithm works on catchment characteristics that are +spatial averages, when splitting, the average condition is apportioned evenly +to each split. In some cases, such as with land cover or elevation, this may +not be appropriate and source data should be used to derive new characteristics. +In addition, this function handles catchment areas for split catchments but +makes no adjustments for the length of flowlines in those catchments. +Therefore, requests for length-weighted mean values may not be appropriate +when working with split catchments.
+# \donttest{
+vars <- data.frame(characteristic_id = c("CAT_IMPV11","CAT_BASIN_AREA"),
+ summary_statistic = c("area_weighted_mean","sum"))
+lookup_table <- data.frame(id = rep(10012268, 2),
+ comid = c(4146596, 4147382),
+ member_comid = c(4146596, 4147382))
+rescale_catchment_characteristics(vars, lookup_table)
+#> # A tibble: 1 × 6
+#> id areasqkm_sum lengthkm_sum CAT_IMPV11_area_wtd percent_nodata_CAT_BA…¹
+#> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 10012268 12.9 6.30 0 0
+#> # ℹ abbreviated name: ¹percent_nodata_CAT_BASIN_AREA_area_wtd
+#> # ℹ 1 more variable: CAT_BASIN_AREA_sum <dbl>
+
+vars <- data.frame(characteristic_id = c("CAT_ELEV_MIN","CAT_ELEV_MAX"),
+ summary_statistic = c("min","max"))
+lookup_table <- data.frame(id = rep(10012268, 2),
+ comid = c(4146596, 4147382),
+ member_comid = c(4146596, 4147382))
+rescale_catchment_characteristics(vars, lookup_table)
+#> # A tibble: 1 × 7
+#> id areasqkm_sum lengthkm_sum percent_nodata_CAT_E…¹ percent_nodata_CAT_E…²
+#> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 1.00e7 12.9 6.30 0 0
+#> # ℹ abbreviated names: ¹percent_nodata_CAT_ELEV_MIN_area_wtd,
+#> # ²percent_nodata_CAT_ELEV_MAX_area_wtd
+#> # ℹ 2 more variables: CAT_ELEV_MIN_min <dbl>, CAT_ELEV_MAX_max <dbl>
+
+vars <- data.frame(characteristic_id = c("CAT_EWT","CAT_TWI", "CAT_BASIN_AREA"),
+ summary_statistic = c("area_weighted_mean", "area_weighted_mean","sum"))
+lookup_table <- data.frame(id = c(10012268, 10012268, 10024047, 10024048),
+ comid = c(4146596, 4147382, 4147396, 4147396),
+ member_comid = c("4146596", "4147382", "4147396.1", "4147396.2"))
+comid_areas <- data.frame(featureid = c("4146596", "4147382", "4147396.1", "4147396.2"),
+ areasqkm = c(0.9558, 11.9790, 6.513294, 1.439999))
+rescale_catchment_characteristics(vars, lookup_table, refactored_areas = comid_areas)
+#> # A tibble: 3 × 9
+#> id areasqkm_sum lengthkm_sum CAT_EWT_area_wtd CAT_TWI_area_wtd
+#> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 10012268 12.9 6.30 -25.5 9.59
+#> 2 10024047 6.51 4.31 -24.6 9.07
+#> 3 10024048 1.44 4.31 -5.44 2.00
+#> # ℹ 4 more variables: percent_nodata_CAT_EWT_area_wtd <dbl>,
+#> # percent_nodata_CAT_TWI_area_wtd <dbl>,
+#> # percent_nodata_CAT_BASIN_AREA_area_wtd <dbl>, CAT_BASIN_AREA_sum <dbl>
+
+ # }
+
+