Skip to content

Commit

Permalink
more CRAN fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Aug 22, 2019
1 parent fb6fb7c commit 07afb79
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 135 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: Tools for Using NHDPlus Data
Version: 0.3.7
Authors@R: person("David", "Blodgett", role = c("aut", "cre"), email = "[email protected]")
Description: Tools for traversing and working with NHDPlus data.
Description: Tools for traversing and working with National Hydrography Dataset Plus (NHDPlus) data. All methods implemented in 'nhdplusTools' are available in the NHDPlus documentation available from the US Environmental Protection Agency <https://www.epa.gov/waterdata/basic-information>.
URL: https://github.com/usgs-r/nhdplusTools
BugReports: https://github.com/usgs-r/nhdplusTools/issues
Depends:
Expand Down
9 changes: 2 additions & 7 deletions R/get_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
#' @return integer COMID
#' @export
#' @examples
#' \dontrun{
#' point <- sf::st_sfc(sf::st_point(c(-76.87479, 39.48233)), crs = 4326)
#' discover_nhdplus_id(point)
#'
#' discover_nldi_sources()
#'
#' nldi_huc12 <- list(featureSource = "huc12pp", featureID = "070700051701")
#' discover_nhdplus_id(nldi_feature = nldi_huc12)
#'
#' nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-08279500")
#' discover_nhdplus_id(nldi_feature = nldi_nwis)
#' }
#'
discover_nhdplus_id <- function(point = NULL, nldi_feature = NULL) {

if (!is.null(point)) {
Expand Down Expand Up @@ -246,6 +240,7 @@ download_nhdplushr <- function(nhd_dir, hu_list, download_files = TRUE) {
#' @export
#' @examples
#' \dontrun{
#' # Not run because this will download a lot of data for the user.
#' download_dir <- download_nhdplushr("./", c("0302", "0303"))
#' get_nhdplushr(download_dir, "nhdplus_0302-03.gpkg")
#' }
Expand Down
37 changes: 5 additions & 32 deletions R/get_nldi.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ discover_nldi_navigation <- function(nldi_feature, tier = "prod") {
#' @export
#' @importFrom utils tail
#' @examples
#' \dontrun{
#' \dontrun{ # Long running example
#' library(sf)
#' library(dplyr)
#'
#' discover_nldi_sources()
#'
#' nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-08279500")
#'
#' nav_options <- discover_nldi_navigation(nldi_nwis)
#'
#' nav_options
#' nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-05428500")
#'
#' navigate_nldi(nldi_feature = nldi_nwis,
#' mode = "upstreamTributaries",
Expand All @@ -79,25 +73,7 @@ discover_nldi_navigation <- function(nldi_feature, tier = "prod") {
#' st_geometry() %>%
#' plot(col = "blue", add = TRUE)
#'
#' navigate_nldi(nldi_feature = nldi_nwis,
#' mode = nav_options[["downstreamMain"]],
#' data_source = "",
#' distance_km = 40) %>%
#' st_geometry() %>%
#' plot(col = "red", add = TRUE)
#'
#' navigate_nldi(nldi_feature = nldi_nwis,
#' mode = "UM", data_source = "nwissite",
#' distance_km = 0) %>%
#' st_geometry() %>%
#' plot(col = "red", add = TRUE)
#'
#' navigate_nldi(nldi_feature = nldi_nwis,
#' mode = "UT",
#' data_source = "huc12pp") %>%
#' st_geometry() %>%
#' plot(col = rgb(255, 205, 205, 100, maxColorValue = 255),
#' pch = 18, add = TRUE)
#'
#' nwissite <- navigate_nldi(nldi_feature = nldi_nwis,
#' mode = "UT",
Expand All @@ -108,6 +84,7 @@ discover_nldi_navigation <- function(nldi_feature, tier = "prod") {
#'
#' nwissite
#' }
#'
navigate_nldi <- function(nldi_feature, mode = "upstreamMain",
data_source = "comid", distance_km = NULL,
tier = "prod") {
Expand Down Expand Up @@ -150,22 +127,18 @@ navigate_nldi <- function(nldi_feature, mode = "upstreamMain",
#' @return sf data.frame with result basin boundary
#' @export
#' @examples
#' \dontrun{
#' library(sf)
#' library(dplyr)
#'
#' discover_nldi_sources()
#'
#' nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-08279500")
#' nldi_nwis <- list(featureSource = "nwissite", featureID = "USGS-05428500")
#'
#' basin <- get_nldi_basin(nldi_feature = nldi_nwis)
#'
#' basin %>%
#' st_geometry() %>%
#' plot()
#'
#' basin
#' }
#' basin
#'
get_nldi_basin <- function(nldi_feature,
tier = "prod") {
Expand Down
55 changes: 27 additions & 28 deletions R/subset_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,7 @@
#' @return path to the saved subset geopackage
#' @export
#' @examples
#' \dontrun{
#' # NHDPlusHR
#' temp_dir <- tempdir()
#' temp_file <- tempfile(fileext = ".zip", tmpdir = temp_dir)
#' download.file("https://usgs-r.github.io/nhdplusTools/data/03_sub.zip",
#' temp_file)
#' unzip(temp_file, exdir = temp_dir)
#'
#' hr_data <- get_nhdplushr(temp_dir,
#' out_gpkg = file.path(temp_dir, "nhd_hr.gpkg"),
#' layers = NULL)
#' flowlines <- sf::read_sf(hr_data, "NHDFlowline")
#'
#' up_ids <- get_UT(flowlines, 15000500028335)
#'
#' sub_nhdhr <- subset_nhdplus(up_ids, file.path(temp_dir, "sub.gpkg"),
#' hr_data, overwrite = TRUE)
#'
#' sf::st_layers(sub_nhdhr)
#'
#' sub_flowline <- sf::read_sf(sub_nhdhr, "NHDFlowline")
#' plot(sf::st_geometry(flowlines), lwd = 0.5)
#' plot(sf::st_geometry(sub_flowline), lwd = 0.6, col = "red", add = TRUE)
#'
#' \dontrun{ # long running example
#' sample_data <- system.file("extdata/sample_natseamless.gpkg",
#' package = "nhdplusTools")
#'
Expand Down Expand Up @@ -104,6 +81,29 @@
#' status = TRUE)
#'
#' sf::st_layers(output_file)
#'
#' # NHDPlusHR
#' temp_dir <- tempdir()
#' temp_file <- tempfile(fileext = ".zip", tmpdir = temp_dir)
#' download.file("https://usgs-r.github.io/nhdplusTools/data/03_sub.zip",
#' temp_file)
#' unzip(temp_file, exdir = temp_dir)
#'
#' hr_data <- get_nhdplushr(temp_dir,
#' out_gpkg = file.path(temp_dir, "nhd_hr.gpkg"),
#' layers = NULL)
#' flowlines <- sf::read_sf(hr_data, "NHDFlowline")
#'
#' up_ids <- get_UT(flowlines, 15000500028335)
#'
#' sub_nhdhr <- subset_nhdplus(up_ids, file.path(temp_dir, "sub.gpkg"),
#' hr_data, overwrite = TRUE)
#'
#' sf::st_layers(sub_nhdhr)
#'
#' sub_flowline <- sf::read_sf(sub_nhdhr, "NHDFlowline")
#' plot(sf::st_geometry(flowlines), lwd = 0.5)
#' plot(sf::st_geometry(sub_flowline), lwd = 0.6, col = "red", add = TRUE)
#' }
#'

Expand Down Expand Up @@ -290,11 +290,10 @@ intersection_write <- function(layer_name, data_path, envelope,
#' @return list containing paths to the .rds files.
#' @export
#' @examples
#' \dontrun{
#' stage_national_data()
#' sample_data <- system.file("extdata/sample_natseamless.gpkg",
#' package = "nhdplusTools")
#'
#' stage_national_data(include = c("attributes", "flowlines","catchment"))
#' }
#' stage_national_data(nhdplus_data = sample_data, output_path = tempdir())
#'
stage_national_data <- function(include = c("attribute",
"flowline",
Expand Down
8 changes: 1 addition & 7 deletions man/discover_nhdplus_id.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/get_nhdplushr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions man/get_nldi_basin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 3 additions & 26 deletions man/navigate_nldi.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/stage_national_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions man/subset_nhdplus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vignettes/nhdplusTools.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ knitr::opts_chunk$set(
fig.width=6,
fig.height=4
)
oldoption <- options(scipen = 9999)
options(scipen = 9999)
```

Expand Down Expand Up @@ -330,3 +331,7 @@ For more info about `get_flowline_index()` see the article `vignette("point_inde
## Refactoring

The NHDPlus tools package has been developed in support of an experimental NHDPlus refactoring workflow to normalize the size of catchments and resolve particular network locations. If this work is of interest, it can be found in the network_refactor branch of this repository.

```{r teardown, include=FALSE}
options(oldoption)
```
Loading

0 comments on commit 07afb79

Please sign in to comment.