A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

nhdplusTools

This package is a growing set of tools for manipulation of hydrographic data using the NHDPlus data model.
https://github.com/DOI-USGS/nhdplusTools

Category: Natural Resources
Sub Category: Water Supply and Quality

Keywords from Contributors

hydrology usgs climate weather noaa ord floods features geospatial-data geospatial-analysis

Last synced: 7 minutes ago
JSON representation

Repository metadata

See official repository at: https://code.usgs.gov/water/nhdplusTools

README.Rmd

          ---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# nhdplusTools 

![R-CMD-check](https://github.com/doi-usgs/nhdplusTools/workflows/R-CMD-check/badge.svg) [![codecov](https://codecov.io/gh/doi-usgs/nhdplusTools/branch/master/graph/badge.svg)](https://app.codecov.io/gh/doi-usgs/nhdplusTools) [![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/nhdplusTools)](https://cran.r-project.org/package=nhdplusTools) [![CRAN](https://www.r-pkg.org/badges/version/nhdplusTools)](https://cran.r-project.org/package=nhdplusTools)

## nhdplusTools: Tools for Accessing and Working with the NHDPlus and other US hydrographic data.

### Recommended Citation:

```
  Blodgett, D., Johnson, J.M., 2022, nhdplusTools: Tools for
  Accessing and Working with the NHDPlus,
  https://doi.org/10.5066/P97AS8JD
```

### Installation:

```{r, eval = FALSE}
install.packages("nhdplusTools")
```

For the latest development:
```{r, eval = FALSE}
install.packages("remotes")
remotes::install_github("DOI-USGS/nhdplusTools")
```

### Resources

For data discovery and access in a U.S. context, start with the [**Getting Started page**](https://doi-usgs.github.io/nhdplusTools/articles/nhdplusTools.html).

Detailed documentation of all the package functions can be found at the [**Reference page**](https://doi-usgs.github.io/nhdplusTools/reference/).

### Data:

`nhdplusTools`, is designed to provide easy access to data associated with the U.S. National Hydrography Dataset. Many functions provided in `nhdplusTools` are thin wrappers around functions that have been migrated to `hydroloom`. 

## Package Vision

The `nhdplusTools` package is intended to provide a reusable set of tools to
subset, relate data to, and generate network attributes for U.S. NHDPlus data. 

General, globally applicable functionality has been moved to [`hydroloom`](https://github.com/DOI-USGS/hydroloom) 

`nhdplusTools` implements a data model consistent with both the [NHDPlus](https://www.epa.gov/waterdata/nhdplus-national-hydrography-dataset-plus)
dataset and the [HY\_Features](http://opengeospatial.github.io/HY_Features/) data 
model. The package aims to provide a set of tools that can be used to build 
workflows using NHDPlus data.

**This vision is intended as a guide to contributors -- conveying what kinds of
contributions are of interest to the package's long term vision. It is a
reflection of the current thinking and is open to discussion and modification.**

### Functional Vision
The following describe a vision for the functionality that should be included
in the package in the long run.

##### Subsetting
The NHDPlus is a very large dataset both spatially and in terms of the number
of attributes it contains. Subsetting utilities will provide network location
discovery, network navigation, and data export utilities to generate spatial
and attribute subsets of the NHDPlus dataset.

##### Indexing
One of the most important roles of the NHDPlus is as a connecting network for
ancillary data and models. The first step in any workflow that uses the
network like this is indexing relevant data to the network. A number of methods
for indexing exist, they can be broken into two main categories: linear
referencing and catchment indexing. Both operate on features represented by
points, lines, and polygons. `nhdplusTools` should eventually support both
linear and catchment indexing.

### Data Model
Given that `nhdplusTools` is focused on working with NHDPlus data, the NHDPlus
data model will largely govern the data model the package is designed to work
with. That said, much of the package functionality also uses concepts from
the HY\_Features standard.  

*Note:* The HY\_Features standard is based on the notion that a "catchment" is a
holistic feature that can be "realized" (some might say modeled) in a number of
ways. In other words, a catchment can *only* be characterized fully through a
collection of different conceptual representations. In NHDPlus, the "catchment"
feature is the polygon feature that describes the drainage divide around the
hydrologic unit that contributes surface flow to a given NHD flowline. While this
may seem like a significant difference, in reality, the NHDPlus COMID identifier
lends itself very well to the HY\_Features catchment concept. The COMID is
used as an identifier for the catchment polygon, the flowline that
connects the catchment inlet and outlet, and value added attributes that
describe characteristics of the catchment's interior. In this way, the COMID
identifier is actually an identifier for a collection of data that
together fully describe an NHDPlus catchment. [See the NHDPlus mapping to
HY_Features in the HY_Features specification.](https://docs.ogc.org/is/14-111r6/14-111r6.html#annexD_1)

Below is a description of the scope of data used by the
`nhdplusTools` package. While other data and attributes may come into scope,
it should only be done as a naive pass-through, as in data subsetting, or
with considerable deliberation.

##### Flowlines and Waterbodies
Flowline geometry is a mix of 1-d streams and 1-d "artificial paths". In order
to complete the set of features meant to represent water, we need to include
waterbody polygons.

##### Catchment Polygons
Catchment polygons are the result of a complete elevation derived hydrography
process with hydro-enforcement applied with both Watershed Boundary Dataset
Hydrologic Units and NHD reaches.

##### Network Attributes
The NHDPlus includes numerous attributes that are built using the network and
allow a wide array of capabilities that would require excessive iteration or
sophisticated and complex graph-oriented data structures and algorithms.

### Architecture
The NHDPlus is a very large dataset. The architecture of this package as it
relates to handling data and what dependencies are used will be very important.

##### Web vs Local Data
`nhdplusTools` offers a mix of web service and local data functionality. 
Web services have generally been avoided for large processes. However, 
applications that would require loading significant amounts of data to perform 
something that can be accomplished with a web service very quickly are supported.
Systems like the [Network Linked Data Index](https://waterdata.usgs.gov/blog/nldi-intro/) are
used for data discovery.

##### NHDPlus Version
Initial package development focused on the [National Seamless NHDPlus](https://www.epa.gov/waterdata/nhdplus-national-data)
database. [NHDPlus High Resolution](https://www.usgs.gov/national-hydrography/nhdplus-high-resolution) is also supported.

### Related similar packages:
https://github.com/mbtyers/riverdist  
https://github.com/jsta/nhdR  
https://github.com/lawinslow/hydrolinks  
https://github.com/mikejohnson51/HydroData    
https://github.com/ropensci/FedData    
https://github.com/hyriver/pygeohydro
... others -- please suggest additions?

### Build notes:
This package uses a convention to avoid building vignettes on CRAN. The `BUILD_VIGNETTES` environment variable must be set to `TRUE`. This is done with a .Renviron file in the package directory with the line `BUILD_VIGNETTES=TRUE`.

Given this, the package should be built locally to include vignettes using:

```r
devtools::build()
```

### Check notes:
In addition to typical R package checking, a Dockerfile is included in this repository. Once built, it can be run with the following command.

```
docker build -t nhdplustools_test .

docker run --rm -it -v $PWD:/src nhdplustools_test /bin/bash -c "cp -r /src/* /check/ && cp /src/.Rbuildignore /check/ && cd /check && Rscript -e 'devtools::build()' && R CMD check --as-cran ../nhdplusTools_*"
```

### Release procedure:
- ensure all checks pass and code coverage is adequate.
- ensure news has been updated
- convert disclaimer to [released form](https://code.usgs.gov/water/sbtools/-/blob/v1.1.14/README.md#L113)
- update version in inst/CITATION file
- update version in code.json file
- Build source package and upload to CRAN
- Once a new version has been accepted by cran,
- ensure pkgdown is up to date
- commit, push, and PR/MR changes
- create release page and tag
- attach cran tar.gz to release page
- update DOI to point to release page
- switch README disclaimer back to ["dev" mode.](https://code.usgs.gov/water/sbtools#disclaimer)
- Update version in Description.
- push an PR/MR changes.


### Contributing:

First, thanks for considering a contribution! I hope to make this package a community created resource
for us all to gain from and won't be able to do that without your help!

1) Contributions should be thoroughly tested with [`testthat`](https://testthat.r-lib.org/).  
2) Code style should attempt to follow the [`tidyverse` style guide.](https://style.tidyverse.org/)  
3) Please attempt to describe what you want to do prior to contributing by submitting an issue.  
4) Please follow the typical github [fork - pull-request workflow.](https://gist.github.com/Chaser324/ce0505fbed06b947d962)  
5) Make sure you use roxygen and run Check before contributing. More on this front as the package matures. 

Other notes:
- consider running `lintr` prior to contributing.
- consider running `goodpractice::gp()` on the package before contributing.
- consider running `devtools::spell_check()` if you wrote documentation.
- this package uses pkgdown. Running `pkgdown::build_site()` will refresh it.

```{r disclaimer, child="DISCLAIMER.md", eval=TRUE}

```

 [
    ![CC0](https://i.creativecommons.org/p/zero/1.0/88x31.png)
  ](https://creativecommons.org/publicdomain/zero/1.0/)

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 875
Total Committers: 11
Avg Commits per committer: 79.545
Development Distribution Score (DDS): 0.088

Commits in past year: 71
Committers in past year: 1
Avg Commits per committer in past year: 71.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
David Blodgett d****t@u****v 798
mike j****0@u****u 33
Marc H. Weber m****6@g****m 9
David Blodgett 8
Lauren Koenig l****r@u****v 6
Jem Stachelek j****a 5
mikejohnson51 m****n@g****u 5
[email protected] j****n@u****v 4
Laura l****o@u****v 3
Taher Chegini t****i@g****m 2
Mike Vlah v****3@g****m 2

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 227
Total pull requests: 208
Average time to close issues: 3 months
Average time to close pull requests: 4 days
Total issue authors: 54
Total pull request authors: 11
Average comments per issue: 2.6
Average comments per pull request: 0.65
Merged pull request: 195
Bot issues: 0
Bot pull requests: 0

Past year issues: 30
Past year pull requests: 25
Past year average time to close issues: 10 days
Past year average time to close pull requests: about 9 hours
Past year issue authors: 13
Past year pull request authors: 1
Past year average comments per issue: 3.47
Past year average comments per pull request: 0.16
Past year merged pull request: 24
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/DOI-USGS/nhdplusTools

Top Issue Authors

  • dblodgett-usgs (134)
  • mikejohnson51 (8)
  • joshualerickson (7)
  • mkoohafkan (5)
  • mjcashman (4)
  • mhweber (4)
  • lindsayplatt (3)
  • jsta (3)
  • kathryn-willi (3)
  • lkoenig-usgs (3)
  • jds485 (3)
  • edzer (2)
  • mdodrill-usgs (2)
  • lucyrandrews (2)
  • tcounihan (2)

Top Pull Request Authors

  • dblodgett-usgs (181)
  • mikejohnson51 (10)
  • jsta (5)
  • lekoenig (3)
  • ldecicco-USGS (2)
  • cheginit (2)
  • vlahm (1)
  • ferna328 (1)
  • edzer (1)
  • mhweber (1)
  • joshualerickson (1)

Top Issue Labels

  • enhancement (25)
  • indexing (6)
  • planning (6)
  • documentation (6)
  • bug (2)
  • wontfix (2)
  • help wanted (1)
  • Testing (1)

Top Pull Request Labels


Package metadata

cran.r-project.org: nhdplusTools

NHDPlus Tools

  • Homepage: https://doi-usgs.github.io/nhdplusTools/ https://github.com/doi-usgs/nhdplusTools/
  • Documentation: http://cran.r-project.org/web/packages/nhdplusTools/nhdplusTools.pdf
  • Licenses: CC0
  • Latest release: 1.3.1 (published 2 months ago)
  • Last Synced: 2025-04-26T14:35:37.701Z (1 day ago)
  • Versions: 33
  • Dependent Packages: 3
  • Dependent Repositories: 14
  • Downloads: 1,112 Last month
  • Rankings:
    • Forks count: 2.591%
    • Stargazers count: 4.813%
    • Dependent repos count: 7.715%
    • Average: 8.162%
    • Downloads: 12.456%
    • Dependent packages count: 13.235%
  • Maintainers (1)

Dependencies

DESCRIPTION cran
  • R >= 4.0 depends
  • R.utils * imports
  • RANN * imports
  • dataRetrieval * imports
  • dplyr * imports
  • fst * imports
  • httr * imports
  • jsonlite * imports
  • magrittr * imports
  • methods * imports
  • pbapply * imports
  • prettymapr * imports
  • rosm * imports
  • sf * imports
  • tidyr * imports
  • tools * imports
  • units * imports
  • utils * imports
  • xml2 * imports
  • zip * imports
  • codetools * suggests
  • data.table * suggests
  • devtools * suggests
  • ggmap * suggests
  • ggplot2 * suggests
  • gifski * suggests
  • knitr * suggests
  • leaflet * suggests
  • lwgeom * suggests
  • markdown * suggests
  • parallel * suggests
  • rmarkdown * suggests
  • s2 * suggests
  • sp * suggests
  • testthat * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact master composite
  • r-lib/actions/setup-r v1 composite
Dockerfile docker
  • rocker/verse devel build

Score: 14.00257916300814