Skip to content

Commit

Permalink
update return values
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Jun 22, 2021
1 parent dc1cf4f commit b4b7d4a
Show file tree
Hide file tree
Showing 42 changed files with 81 additions and 45 deletions.
8 changes: 4 additions & 4 deletions R/downloading_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param download_files boolean if FALSE, only URLs to files will be returned
#' can be hu02s and/or hu04s
#'
#' @return Paths to geodatabases created.
#' @return character Paths to geodatabases created.
#' @importFrom xml2 read_xml xml_ns_strip xml_find_all xml_text
#' @importFrom utils download.file
#' @importFrom zip unzip
Expand Down Expand Up @@ -88,7 +88,7 @@ download_nhdplushr <- function(nhd_dir, hu_list, download_files = TRUE) {
#' @param outdir The folder path where data should be downloaded and extracted
#' @param url the location of the online resource
#' @param progress boolean display download progress?
#' @return the path to the local geodatabase
#' @return character path to the local geodatabase
#' @export
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -130,7 +130,7 @@ download_nhdplusv2 <- function(outdir,
#' https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/WBD/National/GDB/WBD_National_GDB.xml
#' for metadata.
#' @inheritParams download_nhdplusv2
#' @return the path to the local geodatabase
#' @return character path to the local geodatabase
#' @export
#' @importFrom zip unzip
#' @examples
Expand Down Expand Up @@ -161,7 +161,7 @@ download_wbd <- function(outdir,
#' @description This function downloads and decompresses staged RF1 data.
#' See: https://water.usgs.gov/GIS/metadata/usgswrd/XML/erf1_2.xml for metadata.
#' @inheritParams download_nhdplusv2
#' @return the path to the local e00 file
#' @return character path to the local e00 file
#' @export
#' @examples
#' \dontrun{
Expand Down
1 change: 1 addition & 0 deletions R/get_geometry.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param x sf data.frame with one or more flowlines
#' @param position character either "start" or "end"
#' @export
#' @return sf data.frame containing requested nodes
#' @importFrom sf st_crs st_coordinates st_as_sf
#' @importFrom dplyr select group_by filter row_number n ungroup
#' @examples
Expand Down
18 changes: 6 additions & 12 deletions R/get_hydro.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#' @title Find WBD HUC 08 unit subsets
#' @description Subsets the WBD level 08 features by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id WBD HUC08 ID(s)
#' @inherit query_usgs_geoserver return
#' @export

get_huc8 <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
Expand All @@ -15,10 +14,9 @@ get_huc8 <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @title Find WBD HUC 12 unit subsets
#' @description Subsets the WBD level 12 features by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id WBD HUC12 ID(s)
#' @inherit query_usgs_geoserver return
#' @export

get_huc12 <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
Expand All @@ -29,10 +27,9 @@ get_huc12 <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @title Find NHD Water Bodies
#' @description Subsets NHD waterbody features by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id NHD Waterbody COMID(s)
#' @inherit query_usgs_geoserver return
#' @export

get_waterbodies <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
Expand All @@ -45,10 +42,9 @@ get_waterbodies <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @title Find NHD Areas
#' @description Subsets NHD Area features by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id NHD Area COMID(s)
#' @inherit query_usgs_geoserver return
#' @export

get_nhdarea <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
Expand All @@ -60,10 +56,9 @@ get_nhdarea <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @title Find GAGESII Features
#' @description Subsets the gagesII dataset by location (POINT),
#' area (POLYGON), or set of IDs.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param id NWIS Gage ID(s)
#' @inherit query_usgs_geoserver return
#' @export

get_gagesII <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
Expand All @@ -75,12 +70,11 @@ get_gagesII <- function(AOI = NULL, id = NULL, t_srs = NULL, buffer = .5){
#' @description Returns a POINT feature class of active, stream network,
#' NWIS gages for an Area of Interest. If a POINT feature is used as an AOI,
#' then the returned sites within the requested buffer, are sorted by distance (in meters) from that POINT.
#' @inherit query_usgs_geoserver details
#' @inherit query_usgs_geoserver details return
#' @inheritParams query_usgs_geoserver
#' @param buffer numeric. The amount (in meters) to buffer a POINT AOI by
#' for an extended search. Default = 20,000. Returned results are arrange
#' by distance from POINT AOI
#' @inherit query_usgs_geoserver return
#' @importFrom xml2 xml_root xml_children xml_attr read_xml
#' @importFrom sf st_geometry_type st_transform st_buffer st_as_sf
#' st_bbox st_nearest_feature st_distance
Expand Down
2 changes: 1 addition & 1 deletion R/get_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @param realization character. What realization to return.
#' Default is flowline and options include: outlet, flowline, catchment,
#' and all
#' @return a single, or list, of simple feature objects
#' @return sfc a single, or list, of simple feature objects
#' @examples
#' \donttest{
#' point <- sf::st_sfc(sf::st_point(c(-119.845, 34.4146)), crs = 4326)
Expand Down
4 changes: 3 additions & 1 deletion R/get_nhdplushr.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' all will be kept.
#' @param ... parameters passed along to \link{get_hr_data}
#' for "NHDFlowline" layers.
#' @return Response is a list of sf data.frames containing output that may also be written
#' @return sf data.frames containing output that may also be written
#' to a geopackage for later use.
#' @details
#' NHDFlowline is joined to value added attributes prior to being
Expand Down Expand Up @@ -115,6 +115,7 @@ get_nhdplushr <- function(hr_dir, out_gpkg = NULL,
#' @param rename boolean if TRUE, nhdplusTools standard attribute values will
#' be applied.
#' @export
#' @return sf data.frame containing requested data
#' @importFrom sf st_transform st_simplify st_crs st_drop_geometry st_geometry
#' @importFrom sf st_cast st_multilinestring st_zm st_geometry<-
#' @importFrom dplyr select group_by filter ungroup distinct
Expand Down Expand Up @@ -187,6 +188,7 @@ cull_cols <- function(x, keep_cols) {
#' @param flowlines sf data.frame of NHDPlusHR flowlines.
#' @importFrom sf st_zm write_sf st_drop_geometry
#' @importFrom dplyr group_by filter select
#' @return sf data.frame containing standalone network
#' @export
#' @examples
#' \donttest{
Expand Down
4 changes: 3 additions & 1 deletion R/get_nldi.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#' @description Provides access to metadata for characteristics that are returned by `get_nldi_characteristics()`.
#' @param type character "all", "local", "total", or "divergence_routed".
#' @export
#' @return data.frame containing available characteristics
#' @examples
#' chars <- discover_nldi_characteristics()
#' names(chars)
Expand Down Expand Up @@ -143,7 +144,7 @@ get_nldi_basin <- function(nldi_feature) {
#' @title Get NLDI Feature
#' @description Get a single feature from the NLDI
#' @inheritParams navigate_nldi
#' @return sf feature collection with one feature
#' @return sf data.frame with one feature
#' @examples
#' \donttest{
#' get_nldi_feature(list("featureSource" = "nwissite", featureID = "USGS-05428500"))
Expand All @@ -160,6 +161,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
#' @export
#' @examples
#' chars <- get_nldi_characteristics(list(featureSource = "nwissite", featureID = "USGS-05429700"))
Expand Down
2 changes: 2 additions & 0 deletions R/get_paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ get_sorted <- function(x) {
#' @param x two column data.frame with IDs and toIDs. Names are ignored.
#' @param outlets IDs of outlet flowlines
#' @export
#' @return data.frame containing the terminal ID for each outlet
#' @importFrom igraph dfs graph_from_data_frame V
#' @importFrom sf st_drop_geometry
#' @importFrom tidyr unnest
Expand Down Expand Up @@ -351,6 +352,7 @@ get_terminal <- function(x, outlets) {
#' @importFrom dplyr arrange
#' @importFrom methods as
#' @export
#' @return data.frame containing levelpaths for each ID
#' @examples
#' source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))
#'
Expand Down
4 changes: 2 additions & 2 deletions R/get_vaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' file path to the cached file. Will use the user data dir indicated
#' by \link{nhdplusTools_data_dir}.
#' @inherit download_vaa details
#' @return file.path character
#' @return character file path
#' @export
#' @examples
#' get_vaa_path()
Expand Down Expand Up @@ -105,7 +105,7 @@ check_vaa_path <- function(path = get_vaa_path(), download = TRUE) {
#' \href{https://www.hydroshare.org/resource/6092c8a62fac45be97a09bfd0b0bf726/}{here}
#' @inheritParams get_vaa
#' @param force logical. Force data re-download. Default = FALSE
#' @return path to cached data
#' @return character path to cached data
#' @export
#' @importFrom httr GET progress write_disk

Expand Down
5 changes: 4 additions & 1 deletion R/index_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ matcher <- function(coords, points, search_radius, max_matches = 1) {
#' Note 4: See `dfMaxLength` input to sf::st_segmentize() for details of
#' handling of precision parameter.
#'
#' Note 5: "from" is downstream -- 0 is the outlet "to" is upstream -- 100 is the inlet
#'
#' @importFrom dplyr filter select mutate right_join left_join
#' @importFrom dplyr group_by summarise distinct desc lag n arrange
#' @importFrom RANN nn2
Expand Down Expand Up @@ -229,7 +231,7 @@ get_flowline_index <- function(flines, points,
#' @param hydro_location data.frame with two columns. The first should join to the
#' id field of the indexes and the second should be the numeric or ascii metric such as drainage
#' area or GNIS Name.. Names of this data,frame are not used.
#' @return The indexes data.frame deduplicated according to the minimum difference
#' @return data.frame indexes deduplicated according to the minimum difference
#' between the values in the metric columns. If two or more result in the same "minimum"
#' value, duplicates will be returned.
#' @export
Expand Down Expand Up @@ -517,6 +519,7 @@ add_len <- function(x) {
#' @param measure numeric reach measure between 0 and 100
#' @param from numeric flowline from-measure relative to the reach
#' @param to numeric flowline to-measure relative to the reach
#' @return numeric rescaled measure
#' @export
#' @examples
#' rescale_measures(40, 0, 50)
Expand Down
6 changes: 3 additions & 3 deletions R/nhdplusTools.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ assign("nhdpt_dat_dir",
#' @description if left unset, will return the user data dir
#' as returned by \link[tools]{R_user_dir} for this package.
#' @param dir path of desired data directory
#' @return path of data directory (silent when setting)
#' @return character path of data directory (silent when setting)
#' @importFrom tools R_user_dir
#' @export
#' @examples
Expand Down Expand Up @@ -230,7 +230,7 @@ nhdplusTools_data_dir <- function(dir = NULL) {
#' geodatabase or geopackage format.
#' @param path character path ending in .gdb or .gpkg
#' @param warn boolean controls whether warning an status messages are printed
#' @return 1 if set successfully, the path if no input.
#' @return 0 (invisibly) if set successfully, character path if no input.
#' @export
#' @examples
#' nhdplus_path("/data/NHDPlusV21_National_Seamless.gdb")
Expand Down Expand Up @@ -260,7 +260,7 @@ nhdplus_path <- function(path = NULL, warn = FALSE) {
#' @title Align NHD Dataset Names
#' @description this function takes any NHDPlus dataset and aligns the attribute names with those used in nhdplusTools.
#' @param x a \code{sf} object of nhdplus flowlines
#' @return a renamed \code{sf} object
#' @return data.frame renamed \code{sf} object
#' @export
#' @examples
#' source(system.file("extdata/new_hope_data.R", package = "nhdplusTools"))
Expand Down
2 changes: 1 addition & 1 deletion R/plot_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param actually_plot boolean actually draw the plot? Use to get data subset only.
#' @param flowline_only boolean only subset and plot flowlines?
#' @param ... parameters passed on to rosm.
#' @return plot data is returned invisibly in NAD83 Lat/Lon.
#' @return data.frame plot data is returned invisibly in NAD83 Lat/Lon.
#' @details plot_nhdplus supports several input specifications. An unexported function "as_outlet"
#' is used to convert the outlet formats as described below.
#' \enumerate{
Expand Down
1 change: 0 additions & 1 deletion R/prep_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#' @param skip_toCOMID boolean if TRUE, toCOMID will not be added to output.
#' @return data.frame ready to be used with the refactor_flowlines function.
#' @importFrom dplyr select filter left_join group_split group_by bind_rows
#' @family refactor functions
#' @export
#' @examples
#'
Expand Down
1 change: 1 addition & 0 deletions R/run_plus_attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ combine_networks <- function(lp) {
#' split into independent sub-networks. If it exists, it will be read from disk
#' rather than recreated.
#' @param status logical should progress be printed?
#' @return data.frame with added attributes
#' @export
#' @examples
#'
Expand Down
3 changes: 2 additions & 1 deletion R/subset_nhdplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#' and subject to revision. It does not include as many layers and may not
#' be available permenently.
#'
#' @return path to the saved subset geopackage
#' @return character path to the saved subset geopackage
#' @export
#' @examples
#' \donttest{
Expand Down Expand Up @@ -667,6 +667,7 @@ get_flowline_layer_name <- function(nhdplus_data) {
#' @param rpu character e.g. "01a"
#' @param run_make_standalone boolean should the run_make_standalone function be run on result?
#' @export
#' @return data.frame containing subset network
#' @importFrom dplyr filter arrange summarize
#' @importFrom sf st_sf st_drop_geometry
#' @examples
Expand Down
3 changes: 3 additions & 0 deletions man/add_plus_network_attributes.Rd

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

2 changes: 1 addition & 1 deletion man/align_nhdplus_names.Rd

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

2 changes: 1 addition & 1 deletion man/disambiguate_flowline_indexes.Rd

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

3 changes: 3 additions & 0 deletions man/discover_nldi_characteristics.Rd

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

2 changes: 1 addition & 1 deletion man/download_nhdplushr.Rd

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

2 changes: 1 addition & 1 deletion man/download_nhdplusv2.Rd

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

2 changes: 1 addition & 1 deletion man/download_rf1.Rd

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

2 changes: 1 addition & 1 deletion man/download_vaa.Rd

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

2 changes: 1 addition & 1 deletion man/download_wbd.Rd

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

2 changes: 2 additions & 0 deletions man/get_flowline_index.Rd

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

Loading

0 comments on commit b4b7d4a

Please sign in to comment.