Skip to content

Commit

Permalink
Merge pull request #357 from dblodgett-usgs/main
Browse files Browse the repository at this point in the history
v1.0.0 cran release
  • Loading branch information
dblodgett-usgs authored Oct 2, 2023
2 parents c16719d + 023ac2f commit 423ddd6
Show file tree
Hide file tree
Showing 68 changed files with 334 additions and 252 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ README.Rmd
cran-comments.md
^CRAN-SUBMISSION$
temp.R
revdep
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ cran-comments.md
.Renviron
CRAN-SUBMISSION
temp.R
revdep
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ URL: https://doi-usgs.github.io/nhdplusTools/ https://github.com/doi-usgs/nhdplu
BugReports: https://github.com/doi-usgs/nhdplusTools/issues/
Depends:
R (>= 4.0)
Imports: hydroloom, dplyr, sf, units, magrittr, jsonlite, httr, xml2, R.utils, utils, tidyr, methods, maptiles, mapsf, fst, arrow, dataRetrieval, tools, zip, pbapply, future.apply
Suggests: testthat, knitr, rmarkdown, markdown, ggmap, ggplot2, sp, lwgeom, devtools, codetools, data.table, parallel, s2, gifski, leaflet, httptest, future
Imports: hydroloom, dataRetrieval, dplyr, sf, units, magrittr, jsonlite, httr, xml2, R.utils, utils, tidyr, methods, maptiles, mapsf, fst, arrow, tools, zip, pbapply
Suggests: testthat, knitr, rmarkdown, ggmap, ggplot2, lwgeom, gifski, leaflet, httptest, future
License: CC0
Encoding: UTF-8
RoxygenNote: 7.2.3
VignetteBuilder: knitr
Config/testthat/parallel: true
Config/testthat/edition: 3
LazyData: true
Language: en-US
28 changes: 15 additions & 13 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
nhdplusTools 1.0.0
==========

`nhdplusTools` has been split into two packages. A new package [`hydroloom`](https://github.com/DOI-USGS/hydroloom) is now available. It contains all nhdplusTools functionality not related to specific dataset schemas. See [this issue](https://github.com/DOI-USGS/nhdplusTools/issues/307) for details.

## `hydroloom`

v1.0.0 should be backward compatible with v0.7 but deprecation warnings have been added and one previously deprecated function has been removed.
Expand Down Expand Up @@ -35,7 +37,7 @@ Specific functions imported from [`hydroloom`](https://doi-usgs.github.io/hydrol

[See the `hydroloom` reference list for details about these functions.](https://doi-usgs.github.io/hydroloom/reference/index.html)

With these functions migrated to hydroloom, a number of `nhdplusTools` functions are now deprecated in favor of the `hyroloom` implementation.
With these functions migrated to `hydroloom`, a number of `nhdplusTools` functions are now deprecated in favor of the `hyroloom` implementation.

- `make_node_topology()`
- `get_pfaf()`
Expand All @@ -47,7 +49,7 @@ With these functions migrated to hydroloom, a number of `nhdplusTools` functions

In v1.0.0, the `download_nhd()` function was added.

In v1.0.0, the stage_national_data (previously deprecated) function was removed.
In v1.0.0, the `stage_national_data` (previously deprecated) function was removed.

nhdplusTools 0.7.1
==========
Expand Down Expand Up @@ -84,7 +86,7 @@ nhdplusTools 0.6.0

- minor change to behavior of `navigate_nldi` the "origin" will always be named
as such rather than the named 1-element list being dropped to a data.frame.
https://github.com/DOI-USGS/dataRetrieval/issues/623
`https://github.com/DOI-USGS/dataRetrieval/issues/623`
- Address scalability issue with web service downloads. #308
- Add ability to add node topology back to a edge list topology. #302

Expand Down Expand Up @@ -112,7 +114,7 @@ nhdplusTools 0.5.3

v0.5.3 is primarily bug fixes and enhancements.

One notable addition is the addition of the `rpu_boundaries` and `vpu_boundaries` datasets which provide simplified polygons around the RPU and VPU subset domains of the nhdplusV2 dataset.
One notable addition is the addition of the `rpu_boundaries` and `vpu_boundaries` datasets which provide simplified polygons around the RPU and VPU subset domains of the NHDPlusV2 dataset.


nhdplusTools 0.5.2
Expand All @@ -138,7 +140,7 @@ To cite nhdplusTools in publications, please use:
## Improvements
- `get_flowline_index()` and `get_waterbody_index()` units and projection handling was altered. Defaults for the `search_radius` input were changed. Coordinate reference system handling in geoprocessing now relies on the CRS of the provided points rather than the flowlines.
- `get_nldi_basin()` now supports precise basin delineation via a logical "split" parameter as well as the option to retrieve un-simplified basin geometry.
- All network-dependent functions in `nhdplusTools` now return a warning and NULL if the web servicee is unavailable or fails for other reasons. This is according to CRAN policy.
- All network-dependent functions in `nhdplusTools` now return a warning and NULL if the web service is unavailable or fails for other reasons. This is according to CRAN policy.


nhdplusTools 0.5.1
Expand All @@ -157,7 +159,7 @@ nhdplusTools 0.5.0
- The introduction vignette is now very brief with links to others.

## Web Service Wrapper Functions
- New functions `get_raindrop_trace()`, `get_split_catchment()` use a web service to access elevation data and retireve a raindrop trace path to the nearest flowline in nhdplus V2 and a split catchment or basin to a precise point location respectively.
- New functions `get_raindrop_trace()`, `get_split_catchment()` use a web service to access elevation data and retrieve a raindrop trace path to the nearest flowline in nhdplus V2 and a split catchment or basin to a precise point location respectively.
- New functions `get_xs_point()`, `get_xs_points()`, and `get_elev_along_path()` access an elevation data service from the 3D Elevation Program and return cross section / path elevation data.

## Utility Functions
Expand All @@ -166,7 +168,7 @@ nhdplusTools 0.5.0
- New function `get_sorted()` generates a sorted and optionally partitioned version of a dendritic tree.

## Subsetting and data utilities
- New function `subset_vpu()` wraps `subset_rpu()` and will subset a vector procesing unit.
- New function `subset_vpu()` wraps `subset_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.
- `get_vaa()` will now return an updated nhdplus network attribute set derived from multiple improved sources.

Expand All @@ -178,7 +180,7 @@ nhdplusTools 0.5.0

## Plotting
- `plot_nhdplus()` now includes on network and off network waterbodies.
- New function `get_wb_outlet()` finds the outlet flowline of an on-network waterbody. This function works for both nhdplusV2 and hires.
- New function `get_wb_outlet()` finds the outlet flowline of an on-network waterbody. This function works for both NHDPlusV2 and hires.

## Package Internals
- nhdplusTools testing has been updated to use `testthat` edition 3.
Expand All @@ -194,7 +196,7 @@ nhdplusTools 0.4.3
- New function added: `get_streamlevel()` calculates stream level, a bottom up level path order used by nhdplus to categorize complete river levels.

- nhdplusTools internals have started to be refactored to use all lower case attribute names. No changes should be seen from outside the package, but please [report issues](https://github.com/DOI-USGS/nhdplusTools/issues) with attribute naming.
- Package testing now runs in parallel and uses revision 3 of the testthat package.
- Package testing now runs in parallel and uses revision 3 of the `testthat` package.

nhdplusTools 0.4.2
==========
Expand All @@ -209,13 +211,13 @@ nhdplusTools 0.4.1
==========
Version 0.4.1 is a minor release with bug fixes and updates for CRAN policy.

A noteable addition is handling for strictly dendritic topology encoded using a "tocomid" attribute rather than "fromnode" and "tonode" attributes. This functionality was added in subsetting functions and is backward compatible with previous versions.
A notable addition is handling for strictly dendritic topology encoded using a "tocomid" attribute rather than "fromnode" and "tonode" attributes. This functionality was added in subsetting functions and is backward compatible with previous versions.

nhdplusTools 0.4.0
==========
Version 0.4.0 adds new functionality for data access via web services and updates the usability and flexibility of data discovery and subsetting functions. This release includes significant rework of functions related to network navigation and web-service data subsetting.

* Previsouly, `subset_nhdplus()` included internal functionality for downloading data via web service. This code for subsetting NHDPlus via web service was completely rewritten and a number of new web-service data access functions were added. The `get_nhdplus()` function has been added and is for web-service data access only. `subset_nhdplus()`, which will output a subset to a local `.gpkg` file, now uses `get_nhdplus()` for download functionality.
* Previously, `subset_nhdplus()` included internal functionality for downloading data via web service. This code for subsetting NHDPlus via web service was completely rewritten and a number of new web-service data access functions were added. The `get_nhdplus()` function has been added and is for web-service data access only. `subset_nhdplus()`, which will output a subset to a local `.gpkg` file, now uses `get_nhdplus()` for download functionality.
* `navigate_nldi()` and most other [NLDI](https://waterdata.usgs.gov/blog/nldi-intro/) functions are now based on an NLDI client in the [`dataRetrieval`](https://code.usgs.gov/water/dataRetrieval) package. Functionality has been maintained backward compatible with `nhdplusTools` v0.3 as much as possible with some minor modifications to accommodate changes in dataRetrieval. The response format from `navigate_nldi()` has been changed slightly in v0.4, it now includes both the origin feature and navigation type(s) as a list. Two un-needed nldi discovery functions were removed.
* Functions to download and cache all NHDPlus VAAs (in a 195mb `.fst` file) for use in network navigation and other applications have been added. These can be used with any nhdplusTools functions that do not require geometry.
* `get_levelpaths()` now has an `override_factor` parameter that will cause stream leveling to follow the weight rather than the name input if the weight is `override_factor` times larger than the name indication.
Expand All @@ -239,7 +241,7 @@ Version 0.4.0 adds new functionality for data access via web services and update
*Functions Deprecated*
* `stage_national_data()`

*Functions with Consolodated Internals*
*Functions with Consolidated Internals*
* `discover_nhdplus_id()`
* `get_nldi_basin()`
* `get_nldi_feature()`
Expand Down Expand Up @@ -268,7 +270,7 @@ nhdplusTools 0.3.14
* 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 `get_waterbody_index()` to find associations between point locations and waterbodys.
* Added `get_waterbody_index()` to find associations between point locations and waterbodies.
* Added ability to get multiple matches from `get_flowline_index()` with `max_matches` parameter.
* Added ability to download flowlines in `get_flowline_index()` rather than requiring data to be loaded locally.

Expand Down
16 changes: 0 additions & 16 deletions R/A_nhdplusTools.R
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,6 @@ align_nhdplus_names <- function(x){

}

get_cl <- function(cl) {
if(!is.null(cl)) {
if(!requireNamespace("parallel", quietly = TRUE)) {
stop("parallel required if using cores input")
}
if(is.numeric(cl)) {
cl <- parallel::makeCluster(cl)
} else {
if(!"cluster" %in% class(cl)) {
stop("cores must be numeric or a cluster object")
}
}
}
return(cl)
}

#' @importFrom hydroloom st_compatibalize
#' @export
hydroloom::st_compatibalize
Expand Down
2 changes: 1 addition & 1 deletion R/downloading_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ download_rf1 <- function(outdir,

}

#' @title Function to download data from URL to out directory using httr.
#' @title Function to download data from URL to out directory using `httr`.
#' @description General downloader
#' @param dir path to output directory
#' @param url the location of the online resource
Expand Down
2 changes: 1 addition & 1 deletion R/geoserver_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' Spatial Reference System (SRS) as the input AOI. If a individual or set of
#' IDs are used to query, then the default geoserver CRS of EPSG:4326 is
#' preserved. In all cases, a user-defined SRS can be passed to \code{t_srs}
#' which will override all previous SRS's (either input or default).
#' which will override all previous SRS (either input or default).
#' All buffer and distance operations are handled internally using in
#' EPSG:5070 Albers Equal Area projection
#' @param AOI sf (MULTI)POINT or (MULTI)POLYGON. An 'area of interest' can
Expand Down
4 changes: 2 additions & 2 deletions R/get_hydro.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ get_huc8 <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @title Find WBD HUC 12 unit subsets (DEPRECATED)
#' @description Subsets the WBD level 12 features by location (POINT),
#' area (POLYGON), or set of IDs. Derived from a static snapshot of
#' HUC 12s from: https://doi.org/10.5066/P9BTKP3T
#' HUC 12s from: <doi:10.5066/P9BTKP3T>
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id WBD HUC12 ID(s)
Expand Down Expand Up @@ -84,7 +84,7 @@ get_nhdarea <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
}


#' @title Find GAGESII Features
#' @title Find gagesII Features
#' @description Subsets the gagesII dataset by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details return
Expand Down
6 changes: 3 additions & 3 deletions R/get_nldi.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ type_check <- function(type) {
#' @description Navigate the Network Linked Data Index network.
#' @param nldi_feature list with names `featureSource` and `featureID` where
#' `featureSource` is derived from the "source" column of the response of
#' dataRetrieval::get_nldi_sources() and the `featureID` is a known identifier
#' \link[dataRetrieval]{get_nldi_sources} and the `featureID` is a known identifier
#' from the specified `featureSource`.
#' @param mode character chosen from ("UM", "UT", DM", "DD"). See examples.
#' @param data_source character chosen from "source" column of the response
#' of dataRetrieval::get_nldi_sources() or empty string for flowline geometry.
#' of \link[dataRetrieval]{get_nldi_sources} or empty string for flowline geometry.
#' @param distance_km numeric distance in km to stop navigating.
#' @return sf data.frame with result
#' @export
Expand Down Expand Up @@ -210,7 +210,7 @@ get_nldi_feature <- function(nldi_feature) {
#' Metadata for these characteristics can be found using `discover_nldi_characteristics()`.
#' @inheritParams navigate_nldi
#' @inheritParams discover_nldi_characteristics
#' @return data.frame contianing requested characteristics
#' @return data.frame containing requested characteristics
#' @export
#' @examples
#' \donttest{
Expand Down
4 changes: 2 additions & 2 deletions R/get_oaproc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get Raindrop Trace
#' @description Uses a raindrop trace web service to trace the
#' nhdplus digital elevation model to the nearest downslop flowline.
#' nhdplus digital elevation model to the nearest downslope flowline.
#' @param point sfc POINT including crs as created by:
#' \code{sf::st_sfc(sf::st_point(.. ,..), crs)}
#' @param direction character \code{"up"}, \code{"down"}, or \code{"none"}.
Expand Down Expand Up @@ -52,7 +52,7 @@ get_raindrop_trace <- function(point, direction = "down") {
#' @param upstream logical If TRUE, the entire drainage basin upstream
#' of the point provided is returned in addition to the local catchment.
#' @return sf data.frame containing the local catchment, the split portion
#' and optionally the total dranage basin.
#' and optionally the total drainage basin.
#' @export
#' @examples
#' \donttest{
Expand Down
6 changes: 3 additions & 3 deletions R/get_vaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ get_vaa_names <- function(updated_network = FALSE) {
}

#' @title NHDPlusV2 Attribute Subset
#' @description Return requested NHDPlusv2 Attributes.
#' @description Return requested NHDPlusV2 Attributes.
#' @inherit download_vaa details
#' @param atts character The variable names you would like, always includes comid
#' @param path character path where the file should be saved. Default is a
Expand Down Expand Up @@ -157,8 +157,8 @@ check_vaa_path <- function(path, download, updated_network = FALSE) {
}
}

#' @title Download nhdplusVAA data from HydroShare
#' @description downloads and caches nhdplusVAA data on your computer
#' @title Download NHDPlusVAA data from HydroShare
#' @description downloads and caches NHDPlusVAA data on your computer
#' @details The VAA data is a aggregate table of information from the NHDPlusV2
#' elevslope.dbf(s), PlusFlowlineVAA.dbf(s); and NHDFlowlines. All data
#' originates from the EPA NHDPlus Homepage
Expand Down
2 changes: 1 addition & 1 deletion R/plot_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ off_network <- function(waterbody, flowline) {
}

#' Get Waterbody Outlet
#' @param lake_id integer COMID (or character permenent identifier for hi res) of lake.
#' @param lake_id integer COMID (or character permanent identifier for hi res) of lake.
#' @param network data.frame of network features containing wbareacomi, and Hydroseq
#' @export
#' @return sf data.frame with single record of network COMID
Expand Down
4 changes: 2 additions & 2 deletions R/prep_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ filter_coastal <- function(flines) {
#' This is done grouped by terminalpathID because duplicate node
#' ids have been encountered across basins in some datasets. If
#' `remove_coastal` is `TRUE` (the default) either ftype or fcode are
#' required. Uses the \link[hydroloom]{add_toids} functin.
#' required. Uses the \link[hydroloom]{add_toids} function.
#' @param x data.frame with comid, tonode, fromnode, and (optionally)
#' divergence and terminalpa attributes.
#' @param return_dendritic logical if TRUE, a divergence attribute is required
Expand All @@ -193,7 +193,7 @@ filter_coastal <- function(flines) {
#' @param missing integer value to use for terminal nodes.
#' @param remove_coastal logical remove coastal features prior to generating
#' tocomid values? ftype or fcode are required if `TRUE`. fcode == 56600 or
#' fcode == "Coastline" will be fremoved.
#' fcode == "Coastline" will be removed.
#' @param add logical if TRUE, a tocomid column will be added, otherwise
#' a data.frame with two columns will be returned.
#' @return data.frame containing comid and tocomid attributes or all
Expand Down
2 changes: 1 addition & 1 deletion R/rebuild_topology.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ get_hyg <- function(x, add, id = "comid") {
#' Should have id and toid fields in the first and second columns. Names
#' are not used.
#' @return data.frame containing id, fromnode, and tonode attributes or all
#' attributes provided with id, fromnode and tonodde in the first three columns.
#' attributes provided with id, fromnode and tonode in the first three columns.
#' @export
#' @examples
#' source(system.file("extdata/new_hope_data.R", package = "nhdplusTools"))
Expand Down
10 changes: 5 additions & 5 deletions R/rescale_catchments.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rescale_characteristics <- function(vars, lookup_table) {
cols_area_wtd_mean <- c(cols_area_wtd_mean, vars_nodata)
}

# rescale NHDPlusv2 attributes to desired catchments
# rescale NHDPlusV2 attributes to desired catchments
# !note that there are currently no adjustments made for the length of split flowlines
lookup_table |>
group_by(.data$id) |>
Expand All @@ -37,10 +37,10 @@ rescale_characteristics <- function(vars, lookup_table) {
}

#' @description
#' Get catchment area and flowline length for NHDPlusv2 COMID(s) of interest.
#' Get catchment area and flowline length for NHDPlusV2 COMID(s) of interest.
#' If any COMID represents a split catchment, the split catchment areas are
#' returned, along with a column that represents the proportion of the original
#' NHDPlusv2 catchment area that is covered by the split catchment.
#' NHDPlusV2 catchment area that is covered by the split catchment.
#'
#' @param comids integer vector or character vector containing NHDPlusV2 identifiers
#' @param refactored_areas data frame containing columns "featureid" and
Expand Down Expand Up @@ -118,8 +118,8 @@ get_catchment_areas <- function(comids, refactored_areas = NULL){
#' "min," and "max."
#'
#' @param lookup_table 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
#' 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.
#'
Expand Down
Loading

0 comments on commit 423ddd6

Please sign in to comment.