MyNixOS website logo
Description

Access EPA 'ATTAINS' Data.

An R interface to United States Environmental Protection Agency (EPA) Assessment, Total Maximum Daily Load (TMDL) Tracking and Implementation System ('ATTAINS') data. 'ATTAINS' is the EPA database used to track information provided by states about water quality assessments conducted under federal Clean Water Act requirements. ATTAINS information and API information is available at <https://www.epa.gov/waterdata/attains>.

rATTAINS

CRANstatus rATTAINS statusbadge Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. R-CMD-check codecov DOI

rATTAINS provides functions for downloading tidy data from the United States (U.S.) Environmental Protection Agency (EPA) 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 made available through the EPA.

rATTAINS is on CRAN:

install.packages('rATTAINS')

Or install the development version from r-universe:

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. 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:

library(rATTAINS)
state_summary(organization_id = "TCEQMAIN", 
              reporting_cycle = "2020",
              .unnest = FALSE) |>
  tidyr::unnest(reporting_cycles) |> 
  tidyr::unnest(water_types) |> 
  tidyr::unnest(use_attainments)
#> # A tibble: 31 × 16
#>    organization_identifer organization_name organization_type_text
#>    <chr>                  <chr>             <chr>                 
#>  1 TCEQMAIN               Texas             State                 
#>  2 TCEQMAIN               Texas             State                 
#>  3 TCEQMAIN               Texas             State                 
#>  4 TCEQMAIN               Texas             State                 
#>  5 TCEQMAIN               Texas             State                 
#>  6 TCEQMAIN               Texas             State                 
#>  7 TCEQMAIN               Texas             State                 
#>  8 TCEQMAIN               Texas             State                 
#>  9 TCEQMAIN               Texas             State                 
#> 10 TCEQMAIN               Texas             State                 
#> # ℹ 21 more rows
#> # ℹ 13 more variables: reporting_cycle <chr>, water_type_code <chr>,
#> #   units_code <chr>, use_name <chr>, fully_supporting <dbl>,
#> #   fully_supporting_count <int>, use_insufficient_information <dbl>,
#> #   use_insufficient_information_count <int>, not_assessed <dbl>,
#> #   not_assessed_count <int>, not_supporting <dbl>, not_supporting_count <int>,
#> #   parameters <list<tibble[,9]>>

Get a summary about assessed uses, parameters and plans in a HUC12:

df <- huc12_summary(huc = "020700100204",
              .unnest = FALSE)

tidyr::unnest(df, summary_by_use)
#> # A tibble: 5 × 24
#>   huc12        assessment_unit_count total_catchment_area…¹ total_huc_area_sq_mi
#>   <chr>                        <int>                  <dbl>                <dbl>
#> 1 020700100204                    17                   46.1                 46.2
#> 2 020700100204                    17                   46.1                 46.2
#> 3 020700100204                    17                   46.1                 46.2
#> 4 020700100204                    17                   46.1                 46.2
#> 5 020700100204                    17                   46.1                 46.2
#> # ℹ abbreviated name: ¹​total_catchment_area_sq_mi
#> # ℹ 20 more variables: assessed_catchment_area_sq_mi <dbl>,
#> #   assessed_cathcment_area_percent <dbl>,
#> #   assessed_good_catchment_area_sq_mi <dbl>,
#> #   assessed_good_catchment_area_percent <dbl>,
#> #   assessed_unknown_catchment_area_sq_mi <dbl>,
#> #   assessed_unknown_catchment_area_percent <dbl>, …

tidyr::unnest(df, summary_by_parameter_impairments, names_repair = "minimal")
#> # A tibble: 16 × 25
#>    huc12       assessment_unit_count total_catchment_area…¹ total_huc_area_sq_mi
#>    <chr>                       <int>                  <dbl>                <dbl>
#>  1 0207001002…                    17                   46.1                 46.2
#>  2 0207001002…                    17                   46.1                 46.2
#>  3 0207001002…                    17                   46.1                 46.2
#>  4 0207001002…                    17                   46.1                 46.2
#>  5 0207001002…                    17                   46.1                 46.2
#>  6 0207001002…                    17                   46.1                 46.2
#>  7 0207001002…                    17                   46.1                 46.2
#>  8 0207001002…                    17                   46.1                 46.2
#>  9 0207001002…                    17                   46.1                 46.2
#> 10 0207001002…                    17                   46.1                 46.2
#> 11 0207001002…                    17                   46.1                 46.2
#> 12 0207001002…                    17                   46.1                 46.2
#> 13 0207001002…                    17                   46.1                 46.2
#> 14 0207001002…                    17                   46.1                 46.2
#> 15 0207001002…                    17                   46.1                 46.2
#> 16 0207001002…                    17                   46.1                 46.2
#> # ℹ abbreviated name: ¹​total_catchment_area_sq_mi
#> # ℹ 21 more variables: assessed_catchment_area_sq_mi <dbl>,
#> #   assessed_cathcment_area_percent <dbl>,
#> #   assessed_good_catchment_area_sq_mi <dbl>,
#> #   assessed_good_catchment_area_percent <dbl>,
#> #   assessed_unknown_catchment_area_sq_mi <dbl>,
#> #   assessed_unknown_catchment_area_percent <dbl>, …

tidyr::unnest(df, summary_restoration_plans, names_repair = "minimal")
#> # A tibble: 1 × 25
#>   huc12        assessment_unit_count total_catchment_area…¹ total_huc_area_sq_mi
#>   <chr>                        <int>                  <dbl>                <dbl>
#> 1 020700100204                    17                   46.1                 46.2
#> # ℹ abbreviated name: ¹​total_catchment_area_sq_mi
#> # ℹ 21 more variables: assessed_catchment_area_sq_mi <dbl>,
#> #   assessed_cathcment_area_percent <dbl>,
#> #   assessed_good_catchment_area_sq_mi <dbl>,
#> #   assessed_good_catchment_area_percent <dbl>,
#> #   assessed_unknown_catchment_area_sq_mi <dbl>,
#> #   assessed_unknown_catchment_area_percent <dbl>, …

Find statistical surveys completed by an organization:

surveys(organization_id="SDDENR",
        .unnest = FALSE) |> 
  tidyr::unnest(survey_water_groups) |> 
  tidyr::unnest(survey_water_group_use_parameters)
#> # A tibble: 104 × 21
#>    organization_identifier organization_name organization_type_text
#>    <chr>                   <chr>             <chr>                 
#>  1 SDDENR                  South Dakota      State                 
#>  2 SDDENR                  South Dakota      State                 
#>  3 SDDENR                  South Dakota      State                 
#>  4 SDDENR                  South Dakota      State                 
#>  5 SDDENR                  South Dakota      State                 
#>  6 SDDENR                  South Dakota      State                 
#>  7 SDDENR                  South Dakota      State                 
#>  8 SDDENR                  South Dakota      State                 
#>  9 SDDENR                  South Dakota      State                 
#> 10 SDDENR                  South Dakota      State                 
#> # ℹ 94 more rows
#> # ℹ 18 more variables: survey_status_code <chr>, year <int>,
#> #   survey_comment_text <chr>, documents <list<tibble[,8]>>,
#> #   water_type_group_code <chr>, sub_population_code <chr>, unit_code <chr>,
#> #   size <int>, site_number <int>, surey_water_group_comment_text <chr>,
#> #   stressor <chr>, survey_use_code <chr>, survey_category_code <chr>,
#> #   statistic <chr>, metric_value <dbl>, margin_of_error <dbl>, …

Citation

If you use this package in a publication, please cite as:

citation("rATTAINS")
#> 
#> To cite rATTAINS in publications use:
#> 
#>   Schramm, Michael (2021).  rATTAINS: Access EPA 'ATTAINS' Data.  R
#>   package version 1.0.0. doi:10.5281/zenodo.5469911
#>   https://CRAN.R-project.org/package=rATTAINS
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Manual{,
#>     title = {{rATTAINS}: Access EPA 'ATTAINS' Data},
#>     author = {Michael Schramm},
#>     year = {2021},
#>     url = {https://CRAN.R-project.org/package=rATTAINS},
#>     doi = {10.5281/zenodo.5469911},
#>     note = {R package version 1.0.0},
#>   }
Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows