Skip to content

Commit

Permalink
Merge pull request #683 from rckwzrd/issue682
Browse files Browse the repository at this point in the history
Issue682: fix waterservice links and screenshots
  • Loading branch information
ldecicco-USGS authored Nov 29, 2023
2 parents 9d1e034 + e339757 commit 06c2d5e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion R/constructNWISURL.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' @param statType character Only used for statistics service requests. Type(s)
#' of statistics to output for daily values. Default is mean, which is the only
#' option for monthly and yearly report types. See the statistics service documentation
#' at \url{https://waterservices.usgs.gov/rest/Statistics-Service.html} for a
#' at \url{https://waterservices.usgs.gov/docs/statistics/} for a
#' full list of codes.
#' @keywords data import USGS web service
#' @return url string
Expand Down
4 changes: 2 additions & 2 deletions R/readNWISdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu",
#' "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also \code{OlsonNames()}
#' for more information on time zones.
#' @param \dots see \url{https://waterservices.usgs.gov/rest/Site-Service.html} for
#' @param \dots see \url{https://waterservices.usgs.gov/docs/site-service/} for
#' a complete list of options. A
#' list of arguments can also be supplied. One important argument to include is
#' "service". Possible values are "iv"
Expand All @@ -24,7 +24,7 @@
#' statistics service). Note: "measurement" calls go to:
#' \url{https://nwis.waterdata.usgs.gov/usa/nwis} for data requests, and use different call requests schemes.
#' The statistics service has a limited selection of arguments
#' (see \url{https://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html}).
#' (see \url{https://waterservices.usgs.gov/docs/site-service/}).
#'
#' @details This function requires users to create their own arguments
#' based on the NWIS web services. It is a more complicated function to use
Expand Down
12 changes: 6 additions & 6 deletions R/readNWISunit.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#' A list of statistic codes can be found here:
#' \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}.
#' More information on the web service can be found here:
#' \url{https://waterservices.usgs.gov/rest/IV-Service.html}.
#' \url{https://waterservices.usgs.gov/docs/instantaneous-values/}.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @param parameterCd character USGS parameter code. This is usually an 5 digit number.
#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
#' retrieval for the earliest possible record. Simple date arguments are specified in local time.
#' See more information here: \url{https://waterservices.usgs.gov/rest/IV-Service.html}.
#' See more information here: \url{https://waterservices.usgs.gov/docs/instantaneous-values/}.
#' @param endDate character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
#' retrieval for the latest possible record. Simple date arguments are specified in local time.
#' See more information here: \url{https://waterservices.usgs.gov/rest/IV-Service.html}.
#' See more information here: \url{https://waterservices.usgs.gov/docs/instantaneous-values/}.
#' @param tz character to set timezone attribute of dateTime. Default is "UTC", and converts the
#' date times to UTC, properly accounting for daylight savings times based on the data's provided tz_cd column.
#' Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles",
Expand Down Expand Up @@ -425,7 +425,7 @@ readNWISmeas <- function(siteNumbers,
#' depending on the year that the data was collected. See \url{https://waterdata.usgs.gov/usa/nwis/gw}
#' for details about groundwater. By default the returned dates are converted to date objects, unless convertType
#' is specified as FALSE. Sites with non-standard date formats (i.e. lacking a day) can be affected (see examples).
#' See \url{https://waterservices.usgs.gov/rest/GW-Levels-Service.html} for more information.
#' See \url{https://waterservices.usgs.gov/docs/groundwater-levels/} for more information.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
#' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
Expand Down Expand Up @@ -526,7 +526,7 @@ readNWISgwl <- function(siteNumbers,
#' Site statistics retrieval from USGS (NWIS)
#'
#' Retrieves site statistics from the USGS Statistics Web Service beta.
#' See \url{https://waterservices.usgs.gov/rest/Statistics-Service.html} for more information.
#' See \url{https://waterservices.usgs.gov/docs/statistics/} for more information.
#'
#' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number.
#' @param parameterCd character USGS parameter code. This is usually a 5 digit number.
Expand All @@ -552,7 +552,7 @@ readNWISgwl <- function(siteNumbers,
#' @param statType character type(s) of statistics to output for daily values.
#' Default is mean, which is the only
#' option for monthly and yearly report types. See the statistics service documentation
#' at \url{https://waterservices.usgs.gov/rest/Statistics-Service.html} for a full list of codes.
#' at \url{https://waterservices.usgs.gov/docs/statistics/} for a full list of codes.
#' @return A data frame with the following columns:
#' \tabular{lll}{
#' Name \tab Type \tab Description \cr
Expand Down
4 changes: 2 additions & 2 deletions R/whatNWISdata.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' USGS data availability
#'
#' Imports a table of available parameters, period of record, and count. See
#' \url{https://waterservices.usgs.gov/rest/Site-Service.html}
#' \url{https://waterservices.usgs.gov/docs/site-service/}
#' for more information.
#'
#' @param \dots see \url{https://waterservices.usgs.gov/rest/Site-Service.html}
#' @param \dots see \url{https://waterservices.usgs.gov/docs/site-service/}
#' for a complete list of options. A list of arguments can also be supplied.
#' @param convertType logical, defaults to \code{TRUE}. If \code{TRUE}, the function will
#' convert the data to dates, datetimes,
Expand Down
4 changes: 2 additions & 2 deletions R/whatNWISsites.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Site Data Import from NWIS
#'
#' Returns a list of sites from the NWIS web service. This function gets the data from:
#' \url{https://waterservices.usgs.gov/rest/Site-Test-Tool.html}.
#' \url{https://waterservices.usgs.gov/docs/site-service/}.
#' Mapper format is used
#'
#' @param \dots see \url{https://waterservices.usgs.gov/rest/Site-Service.html}
#' @param \dots see \url{https://waterservices.usgs.gov/docs/site-service/}
#' for a complete list of options. A list (or lists) can also be supplied.
#'
#' @return A data frame with at least the following columns:
Expand Down
16 changes: 8 additions & 8 deletions vignettes/dataRetrieval.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ siteINFO <- readNWISsite(siteNumbers)
```

Site information is obtained from:
[https://waterservices.usgs.gov/rest/Site-Test-Tool.html](https://waterservices.usgs.gov/rest/Site-Test-Tool.html)
[https://waterservices.usgs.gov/docs/site-service/](https://waterservices.usgs.gov/docs/site-service/)

Information on the returned data can be found with the `comment` function as described in the [Metadata](#embedded-metadata) section.

Expand Down Expand Up @@ -315,7 +315,7 @@ parameterINFO <- readNWISpCode(parameterCd)

## Daily Data

To obtain daily records of USGS data, use the `readNWISdv` function. The arguments for this function are `siteNumbers`, `parameterCd`, `startDate`, `endDate`, and `statCd` (defaults to "00003"). If you want to use the default values, you do not need to list them in the function call. Daily data is pulled from [https://waterservices.usgs.gov/rest/DV-Test-Tool.html](https://waterservices.usgs.gov/rest/DV-Test-Tool.html).
To obtain daily records of USGS data, use the `readNWISdv` function. The arguments for this function are `siteNumbers`, `parameterCd`, `startDate`, `endDate`, and `statCd` (defaults to "00003"). If you want to use the default values, you do not need to list them in the function call. Daily data is pulled from [https://waterservices.usgs.gov/docs/dv-service/](https://waterservices.usgs.gov/docs/dv-service/).

The dates (start and end) must be in the format "YYYY-MM-DD" (note: the user must include the quotes). Setting the start date to "" (no space) will prompt the program to ask for the earliest date, and setting the end date to "" (no space) will prompt for the latest available date.

Expand Down Expand Up @@ -435,7 +435,7 @@ America/Phoenix
America/Metlakatla
```

Data are retrieved from [https://waterservices.usgs.gov/rest/IV-Test-Tool.html](https://waterservices.usgs.gov/rest/IV-Test-Tool.html). There are occasions where NWIS values are not reported as numbers, instead a common example is "Ice". Any value that cannot be converted to a number will be reported as NA in this package. Site information and measured parameter information is attached to the data frame as attributes. This is discussed further in [metadata](#embedded-metadata) section.
Data are retrieved from [https://waterservices.usgs.gov/docs/instantaneous-values/](https://waterservices.usgs.gov/docs/instantaneous-values/). There are occasions where NWIS values are not reported as numbers, instead a common example is "Ice". Any value that cannot be converted to a number will be reported as NA in this package. Site information and measured parameter information is attached to the data frame as attributes. This is discussed further in [metadata](#embedded-metadata) section.

## Groundwater Level Data

Expand Down Expand Up @@ -531,7 +531,7 @@ The previous examples all took specific input arguments: `siteNumber`, `paramete

### Sites: whatNWISsites

The function `whatNWISsites` can be used to discover NWIS sites based on any query that the NWIS Site Service offers. This is done by using the `...` argument, which allows the user to use any arbitrary input argument. We can then use the service [here](https://waterservices.usgs.gov/rest/Site-Test-Tool.html) to discover many options for searching for NWIS sites. For example, you may want to search for sites in a lat/lon bounding box, or only sites tidal streams, or sites with water quality samples, sites above a certain altitude, etc. The results of this site query generate a URL. For example, the tool provided a search within a specified bounding box, for sites that have daily discharge (parameter code = 00060) and temperature (parameter code = 00010). The generated URL is:
The function `whatNWISsites` can be used to discover NWIS sites based on any query that the NWIS Site Service offers. This is done by using the `...` argument, which allows the user to use any arbitrary input argument. We can then use the service [here](https://waterservices.usgs.gov/docs/site-service) to discover many options for searching for NWIS sites. For example, you may want to search for sites in a lat/lon bounding box, or only sites tidal streams, or sites with water quality samples, sites above a certain altitude, etc. The results of this site query generate a URL. For example, the tool provided a search within a specified bounding box, for sites that have daily discharge (parameter code = 00060) and temperature (parameter code = 00010). The generated URL is:

[https://waterservices.usgs.gov/nwis/site/?format=rdb&bBox=-83.0,36.5,-81.0,38.5&parameterCd=00010,00060&hasDataTypeCd=dv](https://waterservices.usgs.gov/nwis/site/?format=rdb&bBox=-83.0,36.5,-81.0,38.5&parameterCd=00010,00060&hasDataTypeCd=dv)

Expand All @@ -554,13 +554,13 @@ For NWIS data, the function `readNWISdata` can be used. The argument listed in t
Service <- c("dv", "iv", "gwlevels", "qwdata", "measurements", "peak", "stat")
Description <- c("Daily", "Instantaneous", "Groundwater Levels", "Water Quality", "Surface Water Measurements", "Peak Flow", "Statistics Service")
URL <- c(
"<a href='https://waterservices.usgs.gov/rest/DV-Test-Tool.html' target='_blank'>https://waterservices.usgs.gov/rest/DV-Test-Tool.html<a>",
"<a href='https://waterservices.usgs.gov/rest/IV-Test-Tool.html' target='_blank'>https://waterservices.usgs.gov/rest/IV-Test-Tool.html<a>",
"<a href='https://waterservices.usgs.gov/rest/GW-Levels-Test-Tool.html' target='_blank'>https://waterservices.usgs.gov/rest/GW-Levels-Test-Tool.html<a>",
"<a href='https://waterservices.usgs.gov/docs/dv-service/' target='_blank'>https://waterservices.usgs.gov/docs/dv-service/<a>",
"<a href='https://waterservices.usgs.gov/docs/instantaneous-values/' target='_blank'>https://waterservices.usgs.gov/docs/instantaneous-values/<a>",
"<a href='https://waterservices.usgs.gov/docs/groundwater-levels/' target='_blank'>https://waterservices.usgs.gov/docs/groundwater-levels/<a>",
"<a href='https://nwis.waterdata.usgs.gov/nwis/qwdata' target='_blank'>https://nwis.waterdata.usgs.gov/nwis/qwdata<a>",
"<a href='https://waterdata.usgs.gov/nwis/measurements/' target='_blank'>https://waterdata.usgs.gov/nwis/measurements/<a>",
"<a href='https://nwis.waterdata.usgs.gov/usa/nwis/peak/' target='_blank'>https://nwis.waterdata.usgs.gov/usa/nwis/peak/<a>",
"<a href='https://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html' target='_blank'>https://waterservices.usgs.gov/rest/Statistics-Service-Test-Tool.html<a>"
"<a href='https://waterservices.usgs.gov/docs/statistics/' target='_blank'>https://waterservices.usgs.gov/docs/statistics/<a>"
)
tableData <- data.frame(Service,
Expand Down
2 changes: 1 addition & 1 deletion vignettes/statsServiceMap.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vignette: >

# Introduction

This script utilizes the new `dataRetrieval` package access to the [USGS Statistics Web Service](http://waterservices.usgs.gov/rest/Statistics-Service.html). We will be pulling daily mean data using the daily value service in `readNWISdata`, and using the stats service data to put it in the context of the site's history. Here we are retrieving data for July 12th in the Upper Midwest, where a major storm system had recently passed through. You can modify this script to look at other areas and dates simply by modifying the `states` and `storm.date` objects.
This script utilizes the new `dataRetrieval` package access to the [USGS Statistics Web Service](https://waterservices.usgs.gov/docs/statistics/). We will be pulling daily mean data using the daily value service in `readNWISdata`, and using the stats service data to put it in the context of the site's history. Here we are retrieving data for July 12th in the Upper Midwest, where a major storm system had recently passed through. You can modify this script to look at other areas and dates simply by modifying the `states` and `storm.date` objects.

To run this code, we recommend having either `dataRetreival` version 2.5.13 (currently the latest release on CRAN) or version 2.6.1 (currently the latest Github release).

Expand Down
Binary file modified vignettes/waterservices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06c2d5e

Please sign in to comment.