call_api: Send One call to the NOAA API to retrieve hourly water level...

Description Usage Arguments Value Examples

View source: R/retrieve_data.R

Description

call_api() places a single call to the NOAA API to retrieve either hourly water level observations or predictions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
call_api(
  .station,
  .start,
  .stop,
  .which = c("observed", "predicted"),
  .datum = c("MSL", "MTL", "MHW", "MHHW", "MLLW", "MLW", "NAVD", "STND"),
  .units = c("metric", "english"),
  .timefmt = c("gmt", "lst", "lst_ldt"),
  .tz = "UTC"
)

Arguments

.station

Numeric or Character. The code that uniquely identifies a NOAA water level station.

.start

An object that inherits from R's Date class or a string of either "yyyymmdd" or "mm/dd/yyyy" format. The starting date for the period of data retrieval.

.stop

An object that inherits from R's Date class or a string of either "yyyymmdd" or "mm/dd/yyyy" format. The ending date for the period of data retrieval. The NOAA API restricts data retrieval of hourly data to no more than one year. This function will throw an error without sending a request to the NOAA API if your request does not comply with that requirement.

.which

'observed' or 'predicted'

.datum

Character string, from a limited list of options. Specifies the vertical datum used for the returned data. "STND" is a station-specific datum anticipated to be below all observed or predicted water levels, so al lwater levels wil lbe positive numbers. "NAVD" is the National Vertical Datum, useful for relating tides to ground elevations from survey or LIDAR. The other choices are standard tidal datums.

.units

"metric" or "english". The default is "metric".

.timefmt

'gmt', 'lst', or 'lst_ldt'. How would you like the time coordinate defined? Choices are for greenwich mean time (also known as UTC, although that abbreviation does not work here), local standard time (with no adjustments for daylight savings time), or local clock time, which can be confusing, since the data returned is a string (not an internal POSIXct or POSIXlt object). Interpretting the data correctly requires care specifying the timezone.

.tz

An R timezone specification. Used only for converting text-based times deliverd from the API to POSIXct objects. Defaults to 'UTC', for consistency with the default .timefmt = 'gmt'. For local standard time, as specified via .timefmt = 'lst', the easiest way is to specify an offset from UTC. For example, use 'Etc/GMT+5' for the U.S. East Coast. For .timefmt = 'lst_ldt' you will need to figure out how to define your local clock time as a time zone. For the U.S East Coast, .tz = "America/New_York" works. See ?timezone for more information.

Value

A dataframe with columns "datetime" and "water_level"

Examples

1
2
3
4
Providence_station <- 8454000
begin_date <- '20200806'
end_date   <- '20200810'
call_api_observed(Providence_station, begin_date, end_date)

ccb60/SLRSIM documentation built on Jan. 21, 2022, 1:31 a.m.