forked from DOI-USGS/dataRetrieval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
187 lines (110 loc) · 8.1 KB
/
README.Rmd
File metadata and controls
187 lines (110 loc) · 8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
title: "README"
output:
md_document:
variant: gfm
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
warning = FALSE,
message = FALSE,
fig.height = 7,
fig.width = 7
)
library(dataRetrieval)
```
# dataRetrieval <img src="man/figures/hex_logo.png" class="logo" alt="dataRetrieval" style="width:90px;height:auto;" align="right" />
[](https://cran.r-project.org/package=dataRetrieval)
[](https://cran.r-project.org/package=dataRetrieval)
[](https://cran.r-project.org/package=dataRetrieval)
The `dataRetrieval` package was created to simplify the process of loading hydrologic data into the R environment. It is designed to retrieve the major data types of U.S. Geological Survey (USGS) hydrology data that are available on the Web, as well as data from the Water Quality Portal (WQP), which currently houses water quality data from the Environmental Protection Agency (EPA), U.S. Department of Agriculture (USDA), and USGS.
# Introduction
:warning: NWIS web services (readNWIS functions) will be replaced over time by USGS Water Data APIs (read_waterdata_). Read more about it here:
<https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html>
:warning: USGS discrete water-quality data availability and format are changing. To view the status of changes in data availability and code functionality, visit: <https://doi-usgs.github.io/dataRetrieval/articles/Status.html>
If you have additional questions about these changes, email CompTools@usgs.gov.
# What would you like to do?
1. Get instantaneous USGS data (for example, discharge sensor data). Start here: `?read_waterdata_continuous`. If you only need the latest value, you can use the function: `?read_waterdata_latest_continuous`.
2. Get daily USGS data (for example, mean daily discharge). Start here: `?read_waterdata_daily`. If you only need the latest value, you can use the function: `?read_waterdata_latest_daily`.
3. Get discrete USGS groundwater data. Start here: `?read_waterdata_field_measurements`
4. Get discrete water quality data from a cooperative service that integrates publicly available water-quality data from the USGS, EPA, and over 400 state, federal, tribal, and local agencies. Start here: `?readWQPdata`
5. Get USGS discrete water quality data. Start here: `?read_waterdata_samples`
6. Get metadata about USGS time series data, including instantaneous and daily data. Start here: `?read_waterdata_ts_meta`
7. Find Hydro Network-Linked Data Index (NLDI) data. Start here: `?findNLDI`
8. Add a USGS WaterData API token to your R environment. See: <https://doi-usgs.github.io/dataRetrieval/articles/read_waterdata_functions.html#api-tokens>
9. Get the latest status on NWIS and other data access updates. See: <https://doi-usgs.github.io/dataRetrieval/articles/Status.html>
For additional tutorials, see:
[Basic Tutorial](https://doi-usgs.github.io/dataRetrieval/articles/tutorial.html)
[dataRetrieval Introduction Slideshow](https://doi-usgs.github.io/dataRetrieval/tutorials/basic_slides_deck.html#/title-slide)
# Installation of dataRetrieval
To install the `dataRetrieval` package, you must be using R 3.0 or greater and run the following command:
```{r eval=FALSE}
install.packages("dataRetrieval")
```
# New USGS data access
The USGS is planning to modernize all web services in the near future. For each of these updates, `dataRetrieval` will create a new function to access the new services.
## API Token
You can register an API key for use with USGS water data APIs. There are now limits on how many queries can be requested per IP address per hour. If you find yourself running into limits, you can request an API token here: <https://api.waterdata.usgs.gov/signup/>
Then save your token in your .Renviron file like this:
```
API_USGS_PAT = "my_super_secret_token"
```
You can use `usethis::edit_r_environ()` to edit find and open your .Renviron file. You will need to restart R for that variable to be recognized.
## New Features
### Style
New functions will use a "snake case", such as "read_waterdata_samples". Older functions use camel case, such as "readNWISdv". The difference is the underscore between words. This should be a handy way to tell the difference between newer modern data access, and the older traditional functions.
### Structure
Historically, we allowed users to customize their queries via the `...` argument structure. With `...`, users needed to know the exact names of query parameters before using the function. Now, the new functions will include **ALL** possible arguments that the web service APIs support. This will allow users to use tab-autocompletes (available in RStudio and other IDEs). **Users will need to understand that it is not advisable to specify all of these parameters. The systems can get bogged down with redundant query parameters.** We expect this will be easier for users, but it might take some time to smooth out the documentation and test usability. There may be additional consequences, such as users won't be able to build up argument lists to pass into the function.
### Dependencies
As we develop functions for the modern USGS Water Data APIs, we'll continue to explore updating package dependencies.
### Developmental workflow
CRAN-stable documentation will be available on the GitHub pages:
<https://doi-usgs.github.io/dataRetrieval/>
In-development documentation will be available on the USGS GitLab pages:
<https://water.code-pages.usgs.gov/dataRetrieval>
Development of `dataRetrieval` will happen on a git branch called "develop". The "develop" branch will only move to the "main" branch when we submit to CRAN, unless there are bug fixes that pertain to the CRAN release. The "develop" branch WILL change frequently, and there are no promises of future behavior. Users must accept that they are using those functions at their own risk. If you willing to accept this risk, the installation instructions are:
```{r eval=FALSE}
library(remotes)
install_github("DOI-USGS/dataRetrieval",
ref = "develop")
```
# Reporting bugs
Please consider reporting bugs and asking questions on the Issues page:
[https://github.com/DOI-USGS/dataRetrieval/issues](https://github.com/DOI-USGS/dataRetrieval/issues)
# Citations
## Citing the dataRetrieval package
```{r cite, eval=TRUE}
citation(package = "dataRetrieval")
```
## Citing NWIS data
U.S. Geological Survey, 2023, National Water Information System data available on the World Wide Web (USGS Water Data for the Nation), accessed [April 26, 2023], at http://waterdata.usgs.gov/nwis/. http://dx.doi.org/10.5066/F7P55KJN
This can be done using the `create_NWIS_bib` function:
```{r}
dv <- readNWISdv("09010500", "00060")
NWIScitation <- create_NWIS_bib(dv)
NWIScitation
print(NWIScitation, style = "Bibtex")
```
## Citing WQP data
Citations for specific datasets should use this format:
National Water Quality Monitoring Council, YYYY, Water Quality Portal, accessed mm, dd, yyyy, hyperlink_for_query, https://doi.org/10.5066/P9QRKUVJ.
This can be done using the `create_WQP_bib` function:
```{r}
SC <- readWQPqw(siteNumbers = "USGS-05288705",
parameterCd = "00300")
WQPcitation <- create_WQP_bib(SC)
WQPcitation
print(WQPcitation, style = "Bibtex")
```
## Citing Water Quality Portal itself
General Water Quality Portal citations should use the following:
Water Quality Portal. Washington (DC): National Water Quality Monitoring Council, United States Geological Survey (USGS), Environmental Protection Agency (EPA); 2021. https://doi.org/10.5066/P9QRKUVJ.
# Package Support
The Water Mission Area of the USGS supports the development and maintenance of `dataRetrieval`, and most likely further into the future. Resources are available primarily for maintenance and responding to user questions. Priorities on the development of new features are determined by the `dataRetrieval` development team.
```{r disclaimer, child="DISCLAIMER.md", eval=TRUE}
```