read_formwqp | R Documentation |
Format data and station metadata from the Water Quality Portal
read_formwqp(res, sta, org, type, trace = F)
res |
A data frame containing results obtained from the API |
sta |
A data frame containing station metadata obtained from the API |
org |
chr string indicating the organization identifier |
type |
chr string indicating data type to download, one of |
trace |
Logical indicating whether to display progress messages, default is |
This function is used by read_importwqp
to combine, format, and process data (res
) and station metadata (sta
) obtained from the Water Quality Portal for the selected county and data type. The resulting data frame includes the date, time, station identifier, latitude, longitude, variable name, value, unit, and quality flag. Manatee County FIB data (21FLMANA_WQX) will also include an area
column indicating the waterbody name as used by the USF Water Atlas, with some area aggregations. Other county-level FIB data will have a similar column.
A data frame containing formatted water quality and station metadata
read_importwqp
## Not run:
url <- list(
Result = "https://www.waterqualitydata.us/data/Result/search?mimeType=csv&zip=no",
Station = "https://www.waterqualitydata.us/data/Station/search?mimeType=csv&zip=no"
)
headers <- c(
"Content-Type" = "application/json",
"Accept" = "application/zip"
)
body <- list(
organization = c("21FLMANA_WQX"),
sampleMedia = c("Water"),
characteristicType = c("Information", "Nutrient", "Biological, Algae, Phytoplankton,
Photosynthetic Pigments"),
providers = c("STORET"),
siteType = c("Estuary")
)
res <- url[['Result']] %>%
httr::POST(httr::add_headers(headers), body = jsonlite::toJSON(body)) %>%
httr::content('text') %>%
read.csv(text = .)
sta <- url[['Station']] %>%
httr::POST(httr::add_headers(headers), body = jsonlite::toJSON(body)) %>%
httr::content('text') %>%
read.csv(text = .)
# combine and format
read_formwqp(res, sta, '21FLMANA_WQX', type = 'wq')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.