-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
114 lines (74 loc) · 4.45 KB
/
README.Rmd
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png",
dpi = 200
)
```
# rATTAINS
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/rATTAINS)](https://cran.r-project.org/package=rATTAINS)
[![rATTAINS status badge](https://mps9506.r-universe.dev/badges/rATTAINS)](https://mps9506.r-universe.dev)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-CMD-check](https://github.com/mps9506/rATTAINS/workflows/R-CMD-check/badge.svg)](https://github.com/mps9506/rATTAINS/actions)
[![codecov](https://codecov.io/gh/mps9506/rATTAINS/branch/main/graph/badge.svg?token=J45QIKWA8E)](https://app.codecov.io/gh/mps9506/rATTAINS)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5469911.svg)](https://doi.org/10.5281/zenodo.5469911)
<!-- badges: end -->
rATTAINS provides functions for downloading tidy data from the United States (U.S.) Environmental Protection Agency (EPA) [ATTAINS](https://www.epa.gov/waterdata/attains) webservice. ATTAINS is the online system used to track and report Clean Water Act assessments and Total Maximum Daily Loads (TMDLs) in U.S. surface waters. rATTAINS facilitates access to the [public information webservice](https://www.epa.gov/waterdata/get-data-access-public-attains-data) made available through the EPA.
rATTAINS is on CRAN:
```{r eval=FALSE}
install.packages('rATTAINS')
```
Or install the development version from r-universe:
```{r eval=FALSE}
install.packages('rATTAINS',
repos = 'https://mps9506.r-universe.dev')
```
## Functions and webservices
There are eight user available functions that correspond with the first eight web services detailed by [EPA](https://www.epa.gov/sites/default/files/2020-10/documents/attains_how_to_access_web_services_2020-10-28.pdf). All arguments are case sensitive. By default the functions attempt to provide flattened "tidy" data as a single or multiple dataframes. By using the `tidy = FALSE` argument in the function below, the raw JSON will be read into the session for the user to parse if desired. This can be useful since some webservices provide different results based on the query and the tidying process used in rATTAINS might make poor assumptions in the data flattening process. If the function returns unexpected results, try parsing the raw JSON string.
- `state_summary()` provides summary information for assessed uses for organizations and by integrated reporting cycle.
- `huc_12_summary()` provides summary information about impairments, actions, and documents for the specified 12-digit HUC (watershed).
- `actions()` provides a summary of information for particular finalized actions (TMDLs and related).
- `assessments()` provides summary data about the specified assessment decisions by waterbody.
- `plans()` returns a summary of the plans (TMDLs and related) within a specified HUC.
- `domain_values()` returns allowed values in ATTAINS. By default (no arguments) the function returns a list of allowed `domain_names`.
- `assessment_units()` returns a summary of information about the specified assessment units.
- `surveys()` returns results from state statistical survey results in ATTAINS.
# Examples:
Get a summary about assessed uses from the Texas Commission on Environmental Quality:
```{r}
library(rATTAINS)
state_summary(organization_id = "TCEQMAIN",
reporting_cycle = "2020",
.unnest = FALSE) |>
tidyr::unnest(reporting_cycles) |>
tidyr::unnest(water_types) |>
tidyr::unnest(use_attainments)
```
Get a summary about assessed uses, parameters and plans in a HUC12:
```{r}
df <- huc12_summary(huc = "020700100204",
.unnest = FALSE)
tidyr::unnest(df, summary_by_use)
tidyr::unnest(df, summary_by_parameter_impairments, names_repair = "minimal")
tidyr::unnest(df, summary_restoration_plans, names_repair = "minimal")
```
Find statistical surveys completed by an organization:
```{r}
surveys(organization_id="SDDENR",
.unnest = FALSE) |>
tidyr::unnest(survey_water_groups) |>
tidyr::unnest(survey_water_group_use_parameters)
```
## Citation
If you use this package in a publication, please cite as:
```{r}
citation("rATTAINS")
```