This function is largely a wrapper function for dataRetrieval::readNWISuv, but focused on salinity
at the 8 USGS stations in the Mississippi portion of the Mississippi Sound.
Arguments
- stations
Character vector of USGS station IDs. Defaults to all 8 USGS stations located in the Mississippi portion of the Mississippi Sound.
- params
Character vector of USGS parameter codes. Defaults to
00480, which corresponds to salinity.- startDate
Date object or character string in
YYYY-MM-DDformat. Defaults to one month ago based on the system date.- endDate
Date object or character string in
YYYY-MM-DDformat. Defaults to the current system date.- tz
Character string indicating the desired time zone. The underlying USGS function retrieves data in UTC, and this wrapper defaults to
America/Regina- local standard time (does not adjust for daylight saving time).
Value
A named list with 2 or 3 components:
dataA data frame of raw unit-value (instantaneous) data from the USGS.
siteInfoMetadata for the stations, extracted from the attributes of the returned data frame.
daily(Optional)A data frame summarizing daily minimum, mean, and maximum salinity values for each site and date. This is only included if salinity data (
Sal) is detected in the returned dataset.
Details
This function downloads high-frequency data via the USGS NWIS portal. It is specific to Mississippi Sound salinity data and does some processing as well. The function downloads high-frequency water quality data (typically salinity) from the USGS National Water Information System for selected monitoring stations in the Mississippi portion of the Mississippi Sound. The function returns raw data, site metadata, and (if salinity data is present) daily summaries of minimum, mean, and maximum salinity values.
The function relies on several external packages:
dataRetrieval for retrieving and renaming USGS data via
readNWISuv()andrenameNWISColumns()stringr for pattern matching and replacement in variable names via
str_replace()andstr_detect()dplyr for data manipulation, grouping, and summarizing
lubridate for date arithmetic
The default behavior focuses on salinity (parameter code 00480), but any other available parameters can be passed.
Examples
if (FALSE) { # \dontrun{
# Get salinity data for the past month at default stations
result <- get_mssnd_data()
# Retrieve water temp data from two stations
# View daily summary if salinity was included
head(result$daily)
} # }