Skip to contents

Retrieve spring water quality data from APIs

Usage

util_spr_getwq(yrrng, raw = FALSE, verbose = TRUE)

Arguments

yrrng

integer vector of length 2, start and end year, e.g. c(2022, 2024).

raw

logical, if FALSE (default) annual mean concentrations are returned (one row per spring per year). If TRUE, the raw, unaggregated observations are returned instead (one row per spring per sample date), with an additional date column in place of yr.

verbose

logical, if TRUE progress messages are printed.

Value

A data frame with columns spring, tn_mgl, tp_mgl, and tss_mgl, plus yr (one row per spring per year) when raw = FALSE, or date (one row per spring per sample date) when raw = TRUE.

Details

Fetches TN, TP, and TSS concentrations (mg/L) for Lithia, Buckhorn, and Sulphur springs from two external sources, returned either as annual means or as raw observations (see raw).

Lithia and Buckhorn springs are retrieved from the Water Atlas API (GET /api/samplingdata/stream), using Southwest Florida Water Management District (SWFWMD) monitoring stations 17805 (Lithia Main Spring) and 18276 (Buckhorn Main Spring) from the WIN_21FLSWFD data source. This is the same underlying dataset as FDEP's Impaired Waters Rule file but accessed directly via API. TSS is not routinely measured at these stations and will typically be NA, in which case anlz_spr substitutes fixed historical values.

Sulphur Spring data are retrieved via read_importepc, which downloads the Environmental Protection Commission of Hillsborough County (EPC) monitoring spreadsheet. Station 174 corresponds to the Sulphur Spring sampling location and provides monthly TN, TP, and TSS observations.

When raw = FALSE, means are computed across all observations within each calendar year, and TSS values that are NaN (i.e., no valid observations in a year) are converted to NA so that anlz_spr can apply the fixed fallback concentrations. When raw = TRUE, no aggregation is performed; each row reflects the actual sample date, and since TN, TP, and TSS are not always sampled on the same date, some rows may have NA for parameters not measured that day.

See also

Examples

if (FALSE) { # \dontrun{
wqdat <- util_spr_getwq(c(2022, 2024))

# raw, unaggregated observations instead of annual means
wqdat <- util_spr_getwq(c(2022, 2024), raw = TRUE)
} # }