Skip to content

Commit 78e38a1

Browse files
authored
update docs for sc_get_data and lc_get_data and clarify contributions procedre in readme (#73)
1 parent d42662c commit 78e38a1

3 files changed

Lines changed: 43 additions & 28 deletions

File tree

R/lc_get_data.R

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,37 @@
77
#' @author
88
#' Marc Weber
99
#'
10-
#' @param metric Name(s) of metrics to query
10+
#' @param metric Name(s) of metrics to query. Must be character string with comma-delimited list of metrics. \emph{\strong{Not} case-sensitive}.
1111
#' Syntax: name=<name1>,<name2>
1212
#'
1313
#' @param aoi Specify the area of interest described by a metric. By default, all available areas of interest
14-
#' for a given metric are returned.
14+
#' for a given metric are returned. \emph{Case-sensitive}.
1515
#' Syntax: areaOfInterest=<value1>,<value2>
1616
#' Values: catchment|watershed|
1717
#'
18-
#' @param comid Return metric information for specific COMIDs. Needs to be a character string
19-
#' and function will convert to this format if needed.
18+
#' @param comid Return metric information for specific COMIDs. Can be a comma-delimited list, a character vector,
19+
#' or any object that can be coerced to a comma-delimited list with \code{\link[base]{paste}}.
20+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
2021
#' Syntax: comid=<comid1>,<comid2>
2122
#'
2223
#' @param state Return metric information for COMIDs within a specific state. Use a state's abbreviation to
23-
#' query for a given state.
24+
#' query for a given state. One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
25+
#' If specified \emph{and valid}, \code{comid} and \code{county} are ignored. \emph{Case-sensitive}.
2426
#' Syntax: state=<state1>,<state2>
2527
#'
2628
#' @param county Return metric information for COMIDs within a specific county.
2729
#' Users must use the FIPS code, not county name, as a way to disambiguate counties.
30+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}. If specified \emph{and valid}, \code{comid} is ignored.
2831
#' Syntax: county=<county1>,<county1>
2932
#'
3033
#' @param region Return metric information for COMIDs within a specified hydroregion.
31-
#' Hydroregions are specified using full name i.e. 'Region01', 'Region03N', 'Region10L'
34+
#' Hydroregions are specified using full name i.e. \code{'Region01'}, \code{'Region03N'}, \code{'Region10L'}
35+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
36+
#' If specified \emph{and valid}, \code{comid}, \code{county}, and \code{state} are ignored. \emph{Case-sensitive}.
3237
#' Syntax: region=<regionid1>,<regionid2>
3338
#'
34-
#' @param conus Return all COMIDs in the conterminous United States.
35-
#' The default value is false.
39+
#' @param conus Return all COMIDs in the conterminous United States. Character string (\emph{\strong{Not} case-sensitive}) or logical.
40+
#' The default value is false. If true, \code{comid}, \code{county}, \code{state}, and \code{region} are ignored.
3641
#' Values: true|false
3742
#'
3843
#' @param showAreaSqKm Return the area in square kilometers of a given area of interest.
@@ -46,7 +51,7 @@
4651
#' count (COLUMNCOUNT) that the server expects to return in a request. The default value is false.
4752
#' Values: true|false
4853
#'
49-
#' @return A tibble of desired StreamCat metrics
54+
#' @return A tibble of desired StreamCat metrics. If data are missing for all rows of a given metric, then the column for that metric will not exist. If data are missing for only some rows, then they will be specified with NA.
5055
#'
5156
#' @examples
5257
#' \donttest{
@@ -66,6 +71,9 @@
6671
#' aoi='cat,ws', comid='23783629,23794487,23812618')
6772
#'
6873
#' df <- lc_get_data(metric='pcturbmd2006,damdens',
74+
#' aoi='cat,ws', comid=c('23783629','23794487','23812618'))
75+
#'
76+
#' df <- lc_get_data(metric='pcturbmd2006,damdens',
6977
#' aoi='cat,ws', comid='23783629,23794487,23812618',
7078
#' countOnly=TRUE)
7179
#'
@@ -97,7 +105,7 @@ lc_get_data <- function(comid = NULL,
97105
if (aoi == 'catchment') aoi <- 'cat'
98106
if (aoi == 'watershed') aoi <- 'ws'
99107
}
100-
if ((is.null(comid) & is.null(state) & is.null(county) & is.null(region) & is.null(conus)) | is.null(metric) |is.null(aoi)){
108+
if ((is.null(comid) & is.null(state) & is.null(county) & is.null(region) & is.null(conus)) | is.null(metric) | is.null(aoi)){
101109
stop('Must provide at a minimum valid comid, metric and aoi to the function')
102110
}
103111
if (!is.null(conus) & metric=='all'){

R/sc_get_data.R

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,42 @@
77
#' @author
88
#' Marc Weber
99
#'
10-
#' @param metric Name(s) of metrics to query. This is a comma delimited list of metrics or
11-
#' or if metric='all' then all metrics will be queried.
10+
#' @param metric Name(s) of metrics to query. Must be character string with comma-delimited list of metrics,
11+
#' or, if \code{metric='all'} then all metrics will be queried. \emph{\strong{Not} case-sensitive}.
1212
#' Syntax: name=<name1>,<name2>
1313
#'
14-
#' @param aoi Specify the area of interest described by a metric. For riparian area (catrp100 and wsrp100)
15-
#' if the metric does not have data for the riparian area, no data is returned for that AOI.
16-
#' Certain metrics have no AOI specified for StreamCat so AOI needs to be left null. These
17-
#' metrics are: BankfullDepth, BankfullWidth, CHEM_V2_1, CONN, HABT, HYD, ICI, IWI, TEMP, WettedWidth,
18-
#' prg_bmmi, and all the mast, msst, mwst metrics
14+
#' @param aoi Name(s) of areas of interest to query.
15+
#' If a metric does not have data for a given AOI, no data is returned for that AOI.
16+
#' Certain metrics that have no AOI specified for StreamCat need the AOI to be specified as \code{'other'}. These
17+
#' metrics include: BankfullDepth, BankfullWidth, ThalwagDepth (sic), CHEM_V2_1, CONN, HABT, HYD, ICI, IWI, TEMP, WettedWidth,
18+
#' prg_bmmi, and all the mast, msst, mwst metrics. \emph{Case-sensitive}.
1919
#'
2020
#' Syntax: areaOfInterest=<value1>,<value2>
21-
#' Values: cat|ws|catrp100|wsrp100
21+
#' Values: cat|ws|catrp100|wsrp100|other
2222
#'
23-
#' @param comid Return metric information for specific COMIDs. Needs to be a character string
24-
#' and function will convert to this format if needed.
23+
#' @param comid Return metric information for specific COMIDs. Can be a comma-delimited list, a character vector,
24+
#' or any object that can be coerced to a comma-delimited list with \code{\link[base]{paste}}.
25+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
2526
#' Syntax: comid=<comid1>,<comid2>
2627
#'
2728
#' @param state Return metric information for COMIDs within a specific state. Use a state's abbreviation to
28-
#' query for a given state.
29+
#' query for a given state. One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
30+
#' If specified \emph{and valid}, \code{comid} and \code{county} are ignored. \emph{Case-sensitive}.
2931
#' Syntax: state=<state1>,<state2>
3032
#'
3133
#' @param county Return metric information for COMIDs within a specific county.
3234
#' Users must use the FIPS code, not county name, as a way to disambiguate counties.
35+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}. If specified \emph{and valid}, \code{comid} is ignored.
3336
#' Syntax: county=<county1>,<county1>
3437
#'
3538
#' @param region Return metric information for COMIDs within a specified hydroregion.
36-
#' Hydroregions are specified using full name i.e. 'Region01', 'Region03N', 'Region10L'
39+
#' Hydroregions are specified using full name i.e. \code{'Region01'}, \code{'Region03N'}, \code{'Region10L'}
40+
#' One of \code{comid}, \code{county}, \code{state}, or \code{region} is required unless \code{conus='true'}.
41+
#' If specified \emph{and valid}, \code{comid}, \code{county}, and \code{state} are ignored. \emph{Case-sensitive}.
3742
#' Syntax: region=<regionid1>,<regionid2>
3843
#'
39-
#' @param conus Return all COMIDs in the conterminous United States.
40-
#' The default value is false.
44+
#' @param conus Return all COMIDs in the conterminous United States. Character string (\emph{\strong{Not} case-sensitive}) or logical.
45+
#' The default value is false. If true, \code{comid}, \code{county}, \code{state}, and \code{region} are ignored.
4146
#' Values: true|false
4247
#'
4348
#' @param showAreaSqKm Return the area in square kilometers of a given area of interest.
@@ -51,7 +56,7 @@
5156
#' count (COLUMNCOUNT) that the server expects to return in a request. The default value is false.
5257
#' Values: true|false
5358
#'
54-
#' @return A data frame of StreamCat metrics
59+
#' @return A data frame of StreamCat metrics. If data are missing for all rows of a given metric, then the column for that metric will not exist. If data are missing for only some rows, then they will be specified with NA.
5560
#'
5661
#' @examples
5762
#' \donttest{
@@ -74,7 +79,9 @@
7479
#' df <- sc_get_data(metric='pcturbmd2006,damdens',
7580
#' aoi='cat,ws', comid='179,1337,1337420', countOnly='true')
7681
#'
77-
#' df <- sc_get_data(metric='thalwagdepth', comid='179,1337,1337420',aoi='other')
82+
#' df <- sc_get_data(metric='thalwagdepth', comid='179,1337,1337420', aoi='other')
83+
#'
84+
#' df <- sc_get_data(metric='thalwagdepth', comid=c('179','1337','1337420'), aoi='other')
7885
#'
7986
#' df <- sc_get_data(comid='179', aoi='ws', metric='all')
8087
#' }
@@ -115,7 +122,7 @@ sc_get_data <- function(comid = NULL,
115122
aoi <- gsub('riparian_watershed','wsrp100',aoi)
116123
}
117124
}
118-
if ((is.null(comid) & is.null(state) & is.null(county) & is.null(region) & is.null(conus)) | is.null(metric) |is.null(aoi)){
125+
if ((is.null(comid) & is.null(state) & is.null(county) & is.null(region) & is.null(conus)) | is.null(metric) | is.null(aoi)){
119126
stop('Must provide at a minimum valid comid, metric and aoi to the function')
120127
}
121128
if (!is.null(conus) & metric=='all'){

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Contributions to development of the package are welcome and encouraged. Please c
3434
- Contributions should use the standard GitHub [fork - pull-request workflow](https://gist.github.com/Chaser324/ce0505fbed06b947d962)
3535
- We encourage use of the [tidyverse style guide](https://style.tidyverse.org/) for contributions
3636
- Contributions should ideally be tested using [testthat](https://testthat.r-lib.org/)
37-
- If you contribute documentation the package uses pkgdown and running `pkgdown::build_site()` will refresh the pkgdown pages for the package
37+
- If you contribute to documentation, running `devtools::document()` and then `pkgdown::build_site()` will refresh the help docs and pkgdown pages - however, these updates may not be desired in every pull request
3838

3939
### Python Implementation of StreamCat API
4040
[PyNHD](https://github.com/hyriver/pynhd), part of the [HyRiver](https://github.com/hyriver) suite of Python packages, also provides access to StreamCat data via the API in Python, along with other NHDPlus value-added attributes for catchments and catchment and network accumulated values for catchments available via [USGS ScienceBase](https://sciencebase.usgs.gov/)

0 commit comments

Comments
 (0)