Make a request to the /surfacewater/surfacewaterts/ endpoints (surfacewatertsday, surfacewatertsmonth, surfacewatertswateryear) to retrieve surface water station time series data by station abbreviations, station number, or USGS Site IDs within a given date range (start and end dates)
Usage
get_sw_ts(
abbrev = NULL,
station_number = NULL,
usgs_id = NULL,
start_date = "1900-01-01",
end_date = Sys.Date(),
timescale = "day",
api_key = NULL
)
Arguments
- abbrev
character, station abbreviation
- station_number
character, surface water station number
- usgs_id
character, USGS Site ID
- start_date
character date to request data start point YYYY-MM-DD. Default is start date is "1900-01-01".
- end_date
character date to request data end point YYYY-MM-DD. Default end date is the current date the function is run.
- timescale
character indicating the time series time step. Either "day", "month", "year". Default is to return daily time series.
- api_key
character, API authorization token, optional. If more than maximum number of requests per day is desired, an API key can be obtained from CDSS.
Examples
if (FALSE) {
# Retrieve surface water daily time series
sw_ts_day <-
get_sw_ts(
abbrev = "CLAFTCCO",
start_date = "2000-01-01",
end_date = "2022-01-01",
timescale = "day"
)
# plot daily flow
plot(sw_ts_day$value~sw_ts_day$datetime, type = "s")
# Retrieve surface water monthly time series
sw_ts_month <-
get_sw_ts(
abbrev = "CLAFTCCO",
start_date = "2000-01-01",
end_date = "2022-01-01",
timescale = "month"
)
# plot average monthly flow
plot(sw_ts_month$avg_qcfs~sw_ts_month$datetime, type = "s")
# Retrieve surface water water year time series
sw_ts_year <-
get_sw_ts(
abbrev = "CLAFTCCO",
start_date = "2000-01-01",
end_date = "2022-01-01",
timescale = "wateryear"
)
# plot average water year flow
plot(sw_ts_year$avg_qcfs~sw_ts_year$water_year, type = "s")
}