Skip to content

Commit

Permalink
Re-build README.Rmd
Browse files Browse the repository at this point in the history
  • Loading branch information
mps9506 committed May 15, 2024
1 parent dcec5e5 commit f1a13eb
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 110 deletions.
225 changes: 115 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ However, arguments can be looked up here:
## echoWaterGetFacilityInfo() will return a dataframe or simple features (sf) dataframe.

df <- echoWaterGetFacilityInfo(output = "df",
xmin = '-96.387509',
ymin = '30.583572',
xmax = '-96.281422',
ymax = '30.640008',
p_c1lon = '-96.387509',
p_c1lat = '30.583572',
p_c2lon = '-96.281422',
p_c2lat = '30.640008',
p_ptype = "NPD")

head(df)
#> # A tibble: 4 × 26
#> CWPName SourceID CWPStreet CWPCity CWPState CWPStateDistrict CWPZip
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 CARTER CREEK WWTP TX00471… 2200 NOR… COLLEG… TX 09 77845
#> 2 CENTRAL UTILITY P… TX00027… 222 IREL… COLLEG… TX 09 77843
#> 1 CARTERS CREEK WWTP TX00471… 2200 NOR… COLLEG… TX 09 77845
#> 2 CENTRAL UTILITY P… TX00027… 1584 TAMU COLLEG… TX 09 77843
#> 3 HEAT TRANSFER RES… TX01065… 0.25MI S… COLLEG… TX 09 77845
#> 4 TURKEY CREEK WWTP TX00624… 3000FT W… BRYAN TX 09 77807
#> # ℹ 19 more variables: MasterExternalPermitNmbr <chr>, RegistryID <chr>,
#> # CWPCounty <chr>, CWPEPARegion <chr>, FacDerivedHuc <chr>,
#> # EPASystem <chr>, Statute <chr>, FacStdCountyName <chr>,
#> # CWPNAICSCodes <chr>, FacLat <dbl>, FacLong <dbl>,
#> # CWPTotalDesignFlowNmbr <dbl>, DschToMs4 <chr>, ExposedActivity <chr>,
#> # NPDESDataGroupsDescs <chr>, MsgpFacilityInspctnSmmry <chr>,
#> # MsgpCorrectiveActionSmmry <chr>, AIRIDs <chr>, NPDESIDs <chr>,
#> # SDWAIDs <chr>, AlrExceeds1yr <dbl>, CertifiedDate <date>
#> # CWPTotalDesignFlowNmbr <dbl>, AIRIDs <chr>, CensusBlockGroup <chr>,
#> # MileavgOver90CountSt <dbl>, MileOver90CountSt <dbl>,
#> # SupOver80CountUsSearch <chr>, SupMileavgOver80CountUs <dbl>,
#> # SupMileOver80CountUs <dbl>, SupMileOver80CountUsSearch <chr>,

The ECHO database can provide over 270 different columns. echor returns
a subset of these columns that should work for most users. However, you
Expand All @@ -85,60 +85,54 @@ below, the `qcolumns` argument indicates the dataframe will include
plant name, 8-digit HUC, latitude, longitude, and total design flow.

df <- echoWaterGetFacilityInfo(output = "df",
xmin = '-96.387509',
ymin = '30.583572',
xmax = '-96.281422',
ymax = '30.640008',
p_c1lon = '-96.387509',
p_c1lat = '30.583572',
p_c2lon = '-96.281422',
p_c2lat = '30.640008',
qcolumns = '1,14,23,24,25',
p_ptype = "NPD")
head(df)
#> # A tibble: 4 × 6
#> CWPName SourceID FacDerivedHuc CWPNAICSCodes FacLat FacLong
#> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 CARTER CREEK WWTP TX0047163 12070103 <NA> 30.6 -96.3
#> 2 CENTRAL UTILITY PLANT TX0002747 12070103 <NA> 30.6 -96.3
#> 3 HEAT TRANSFER RESEARCH TX0106526 12070101 <NA> 30.6 -96.4
#> 4 TURKEY CREEK WWTP TX0062472 12070101 <NA> 30.6 -96.4
#> CWPName SourceID FacStdCountyName CWPNAICSCodes FacLat FacLong
#> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 CARTERS CREEK WWTP TX0047163 BRAZOS COUNTY <NA> 30.6 -96.3
#> 2 CENTRAL UTILITY PLANT TX0002747 BRAZOS COUNTY <NA> 30.6 -96.3
#> 3 HEAT TRANSFER RESEARCH TX0106526 BRAZOS COUNTY <NA> 30.6 -96.4
#> 4 TURKEY CREEK WWTP TX0062472 BRAZOS COUNTY <NA> 30.6 -96.4

When returned as sf dataframes, the data is suitable for immediate
spatial plotting or analysis **note: the spatial data endpoints do not
currently appear to be functioning**
spatial plotting or analysis.

library(ggspatial)
library(sf)
library(ggrepel)
library(purrr)
library(prettymapr)

df <- echoWaterGetFacilityInfo(output = "sf",
xmin = '-96.387509',
ymin = '30.583572',
xmax = '-96.281422',
ymax = '30.640008',
p_c1lon = '-96.387509',
p_c1lat = '30.583572',
p_c2lon = '-96.281422',
p_c2lat = '30.640008',
p_ptype = "NPD")

##to make labels, need to map the coords and use geom_text :(
## can't help but think there is an easier way to do this

df <- df %>%
mutate(
coords = map(geometry, st_coordinates),
coords_x = map_dbl(coords, 1),
coords_y = map_dbl(coords, 2)
)

ggplot(df) +
annotation_map_tile(zoomin = -1, progress = "none") +
geom_sf(inherit.aes = FALSE, shape = 21,
color = "darkred", fill = "darkred",
size = 2, alpha = 0.25) +
geom_label_repel(data = df, aes(x = coords_x, y = coords_y, label = SourceID),
geom_label_repel(data = df, aes(label = SourceID,
geometry = geometry),
stat = "sf_coordinates",
point.padding = .5, min.segment.length = 0.1,
size = 2, color = "dodgerblue") +
theme_mps_noto() +
labs(x = "Longitude", y = "Latitude",
title = "NPDES permits near Texas A&M",
caption = "Source: EPA ECHO database")

<img src="man/figures/README-example3-1.png" width="100%" />

### Download discharge/emissions data

Use `echoGetEffluent()` or `echoGetCAAPR()` to download tidy dataframes
Expand Down Expand Up @@ -169,85 +163,96 @@ that all variables are returned as *character* vectors.

sessioninfo::platform_info()
#> setting value
#> version R version 4.3.1 (2023-06-16)
#> os Ubuntu 22.04.2 LTS
#> version R version 4.4.0 (2024-04-24)
#> os Ubuntu 22.04.4 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
#> date 2023-06-22
#> pandoc 2.19.2 @ /usr/bin/ (via rmarkdown)
#> date 2024-05-15
#> pandoc 3.1.11 @ /opt/hostedtoolcache/pandoc/3.1.11/x64/ (via rmarkdown)

sessioninfo::package_info()
#> ! package * version date (UTC) lib source
#> bit 4.0.5 2022-11-15 [1] CRAN (R 4.3.1)
#> bit64 4.0.5 2020-08-30 [1] CRAN (R 4.3.1)
#> P class 7.3-22 2023-05-03 [?] CRAN (R 4.3.1)
#> classInt 0.4-9 2023-02-28 [1] CRAN (R 4.3.1)
#> cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.1)
#> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.1)
#> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.1)
#> curl 5.0.1 2023-06-07 [1] CRAN (R 4.3.1)
#> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.3.1)
#> digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.1)
#> dplyr * 1.1.2 2023-04-20 [1] CRAN (R 4.3.1)
#> e1071 1.7-13 2023-02-01 [1] CRAN (R 4.3.1)
#> echor * 0.1.9 2023-06-22 [1] local
#> evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.1)
#> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.1)
#> farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.1)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.1)
#> fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.1)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.1)
#> ggplot2 * 3.4.2 2023-04-03 [1] CRAN (R 4.3.1)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.1)
#> gtable 0.3.3 2023-03-21 [1] CRAN (R 4.3.1)
#> highr 0.10 2022-12-22 [1] CRAN (R 4.3.1)
#> hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.1)
#> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.1)
#> httr 1.4.6 2023-05-08 [1] CRAN (R 4.3.1)
#> jsonlite 1.8.5 2023-06-05 [1] CRAN (R 4.3.1)
#> P KernSmooth 2.23-21 2023-05-03 [?] CRAN (R 4.3.1)
#> knitr 1.43 2023-05-25 [1] CRAN (R 4.3.1)
#> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.3.1)
#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.1)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.1)
#> P mpsTemplates * 0.2.0 2023-06-20 [?] Github (mps9506/mpsTemplates@d7a070e)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.1)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.1)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.1)
#> plyr 1.8.8 2022-11-11 [1] CRAN (R 4.3.1)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.3.1)
#> progress 1.2.2 2019-05-16 [1] CRAN (R 4.3.1)
#> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.3.1)
#> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.3.1)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.1)
#> P ragg * 1.2.5 2023-01-12 [?] RSPM (R 4.3.0)
#> Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.3.1)
#> readr 2.1.4 2023-02-10 [1] CRAN (R 4.3.1)
#> P renv 0.17.3 2023-04-06 [?] RSPM (R 4.3.0)
#> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.1)
#> rmarkdown 2.22 2023-06-01 [1] CRAN (R 4.3.1)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.1)
#> scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.1)
#> sessioninfo 1.2.2 2021-12-06 [1] any (@1.2.2)
#> sf 1.0-13 2023-05-24 [1] CRAN (R 4.3.1)
#> systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.3.1)
#> P textshaping 0.3.6 2021-10-13 [?] RSPM (R 4.3.0)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.1)
#> tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.3.1)
#> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.1)
#> tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.3.1)
#> units 0.8-2 2023-04-27 [1] CRAN (R 4.3.1)
#> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.1)
#> vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.1)
#> vroom 1.6.3 2023-04-28 [1] CRAN (R 4.3.1)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.3.1)
#> xfun 0.39 2023-04-20 [1] CRAN (R 4.3.1)
#> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.1)
#> ! package * version date (UTC) lib source
#> abind 1.4-5 2016-07-21 [1] CRAN (R 4.4.0)
#> bit 4.0.5 2022-11-15 [1] CRAN (R 4.4.0)
#> bit64 4.0.5 2020-08-30 [1] CRAN (R 4.4.0)
#> P class 7.3-22 2023-05-03 [?] CRAN (R 4.4.0)
#> classInt 0.4-10 2023-09-05 [1] CRAN (R 4.4.0)
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.4.0)
#> P codetools 0.2-20 2024-03-31 [?] CRAN (R 4.4.0)
#> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.4.0)
#> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.4.0)
#> curl 5.2.1 2024-03-01 [1] CRAN (R 4.4.0)
#> DBI 1.2.2 2024-02-16 [1] CRAN (R 4.4.0)
#> digest 0.6.35 2024-03-11 [1] CRAN (R 4.4.0)
#> dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.4.0)
#> e1071 1.7-14 2023-12-06 [1] CRAN (R 4.4.0)
#> echor * 0.1.9.9999 2024-05-15 [1] local
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.4.0)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.0)
#> farver 2.1.2 2024-05-13 [1] CRAN (R 4.4.0)
#> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0)
#> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.0)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0)
#> ggrepel * 0.9.5 2024-01-10 [1] CRAN (R 4.4.0)
#> ggspatial * 1.1.9 2023-08-17 [1] CRAN (R 4.4.0)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.4.0)
#> gtable 0.3.5 2024-04-22 [1] CRAN (R 4.4.0)
#> highr 0.10 2022-12-22 [1] CRAN (R 4.4.0)
#> hms 1.1.3 2023-03-21 [1] CRAN (R 4.4.0)
#> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#> httr 1.4.7 2023-08-15 [1] CRAN (R 4.4.0)
#> jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.4.0)
#> P KernSmooth 2.23-22 2023-07-10 [?] CRAN (R 4.4.0)
#> knitr 1.46 2024-04-06 [1] CRAN (R 4.4.0)
#> labeling 0.4.3 2023-08-29 [1] CRAN (R 4.4.0)
#> P lattice 0.22-6 2024-03-20 [?] CRAN (R 4.4.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.0)
#> P mpsTemplates * 0.2.0 2024-05-15 [?] Github (mps9506/mpsTemplates@d7a070e)
#> munsell 0.5.1 2024-04-01 [1] CRAN (R 4.4.0)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.0)
#> plyr 1.8.9 2023-10-02 [1] CRAN (R 4.4.0)
#> png 0.1-8 2022-11-29 [1] CRAN (R 4.4.0)
#> prettymapr * 0.2.5 2024-02-23 [1] CRAN (R 4.4.0)
#> prettyunits 1.2.0 2023-09-24 [1] CRAN (R 4.4.0)
#> progress 1.2.3 2023-12-06 [1] CRAN (R 4.4.0)
#> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.4.0)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.4.0)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0)
#> P ragg * 1.3.1 2024-05-06 [?] RSPM (R 4.4.0)
#> raster 3.6-26 2023-10-14 [1] CRAN (R 4.4.0)
#> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.4.0)
#> readr 2.1.5 2024-01-10 [1] CRAN (R 4.4.0)
#> renv 1.0.7 2024-04-11 [1] RSPM (R 4.4.0)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.4.0)
#> rmarkdown 2.26 2024-03-05 [1] CRAN (R 4.4.0)
#> rosm 0.3.0 2023-08-27 [1] CRAN (R 4.4.0)
#> scales 1.3.0 2023-11-28 [1] CRAN (R 4.4.0)
#> sessioninfo 1.2.2 2021-12-06 [1] any (@1.2.2)
#> sf * 1.0-16 2024-03-24 [1] CRAN (R 4.4.0)
#> sp 2.1-4 2024-04-30 [1] CRAN (R 4.4.0)
#> systemfonts 1.1.0 2024-05-15 [1] CRAN (R 4.4.0)
#> terra 1.7-71 2024-01-31 [1] CRAN (R 4.4.0)
#> P textshaping 0.3.7 2023-10-09 [?] RSPM (R 4.4.0)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.4.0)
#> tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.4.0)
#> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.0)
#> tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.4.0)
#> units 0.8-5 2023-11-28 [1] CRAN (R 4.4.0)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.0)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.0)
#> vroom 1.6.5 2023-12-05 [1] CRAN (R 4.4.0)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.4.0)
#> xfun 0.44 2024-05-15 [1] CRAN (R 4.4.0)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.4.0)
#>
#> [1] /home/runner/.cache/R/renv/library/echor-4ec080d0/R-4.3/x86_64-pc-linux-gnu
#> [2] /home/runner/.cache/R/renv/sandbox/R-4.3/x86_64-pc-linux-gnu/5cd49154
#> [1] /home/runner/.cache/R/renv/library/echor-4ec080d0/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu
#> [2] /home/runner/.cache/R/renv/sandbox/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/3df92652
#>
#> P ── Loaded and on-disk path mismatch.
Binary file modified man/figures/README-example3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-2-1.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 f1a13eb

Please sign in to comment.