Skip to contents

Get weather observations.

Usage

get_observations(
  sources,
  reference_time,
  elements,
  max_age = NULL,
  limit = NULL,
  time_offsets = NULL,
  time_resolutions = NULL,
  time_series_ids = NULL,
  performance_categories = NULL,
  exposure_categories = NULL,
  qualities = NULL,
  levels = NULL,
  include_extra = NULL,
  fields = NULL,
  version = "v0",
  format = c("jsonld", "csv"),
  client = get_frost_client(),
  auth_type = c("basic", "oauth"),
  flatten = TRUE,
  return_response = FALSE
)

Arguments

sources

character: Source (station) ID, e.g. 'SN18700'.

reference_time

character: Time range to get observations for, in ISO-8601 format.

elements

character: Elements. See `get_elements()` for available values.

max_age

character: The maximum observation age as an ISO-8601 period.

limit

integer: The maximum number of observation times to be returned for each source/element combination

time_offsets

character: The time offsets to get observations for, specified as ISO-8601 periods.

time_resolutions

character: The time resolutions to get observations for, specified as ISO-8601 periods.

time_series_ids

integer: The internal time series IDs to get observations for. Defaults to 0.

performance_categories

character: The performance categories to get observations, e.g "A", "B" etc.

exposure_categories

integer: The exposure categories to get observations for, e.g. 1, 2 etc.

qualities

integer: The qualities to get observations for, e.g. 1, 2 etc.

levels

numeric: The sensor levels to get observations for, e.g. 0.1, 2, 10, 20.

include_extra

integer: If 1 extra data is returned.

fields

character: Fields to return in the response.

version

character: API version.

format

character: Response format.

client

list: List with client id and secret. Defaults to the `MET_FROST_ID` and `MET_FROST_SECRET` environment variables.

auth_type

character: Authentication method, either 'basic' or 'oauth'.

flatten

logical: If TRUE the response is transformed to a table.

return_response

logical: If TRUE a list of class `frost_api` is returned, including the raw `httr2_response`.

Value

tibble or list

Details

For possible input parameters see `get_sources()`, `get_elements()`, and `get_observations_timeseries()`.

Examples

if (FALSE) {
# Example query
df <- get_observations(
  sources = c("SN18700", "SN90450"),
  reference_time = "2010-04-01/2010-04-03",
  elements = c(
    "mean(air_temperature P1D)",
    "sum(precipitation_amount P1D)",
    "mean(wind_speed P1D)"
  )
)
}