Learn R Programming

openmeteo (version 0.2.4)

weather_history: Retrieve historical weather data from the Open-Meteo API

Description

weather_history() calls the Open-Meteo Historical Weather API to obtain weather data for a given location and historical time period.

Refer to the API documentation at: https://open-meteo.com/en/docs/historical-weather-api

Usage

weather_history(
  location,
  start,
  end,
  hourly = NULL,
  daily = NULL,
  response_units = NULL,
  model = NULL,
  timezone = "auto"
)

Value

Specified weather forecast data for the given location and time

Arguments

location

Required. The location for which data will be retrieved. Supplied as either a c(latitude,longitude) WGS84 coordinate pair or a place name string (with co-ordinates obtained via geocode()).

start, end

Required. Start and end dates in ISO 8601 (e.g. "2020-12-31").

hourly, daily

At least one required. A weather variable accepted by the API, or list thereof. See details below.

response_units

Supply to convert temperature, windspeed, or precipitation units. This defaults to: list(temperature_unit = "celsius", windspeed_unit = "kmh", precipitation_unit = "mm")

model

Supply to specify a model for re-analysis.

timezone

specify timezone for time data as a string, i.e. "australia/sydney" (defaults to "auto", the timezone local to the specified location).

Details

You will need to specify at least one weather variable, such as temperature, that you want historical data for. These variables have been sampled or aggregated at hourly or daily intervals, and can be supplied as a list to request multiple variables over the same time period.

Example Hourly historical weather variables include:

VariableDescription
temperature_2mAir temperature at 2 meters above ground
precipitationSum of rain, showers, and snow over the preceding hour
windspeed_10mWind speed at 10 meters above ground
cloudcoverTotal cloud cover as an area fraction
pressure_mslAtmospheric air pressure at mean sea level

Example Daily historical weather variables include:

VariableDescription
temperature_2m_maxMaximum daily air temperature at 2 meters above ground
precipitation_sumSum of rain, showers, and snow over the preceding day
windspeed_10m_maxMaximum daily wind speed at 10 meters above ground

Full documentation for the historical weather API is available at: https://open-meteo.com/en/docs/historical-weather-api

You can also call weather_variables() to retrieve an (incomplete) shortlist of valid hourly and daily weather variables.

Examples

Run this code
# \donttest{
# obtain cloud cover history for London over 2020
weather_history("London",
  start = "2020-01-01",
  end = "2021-12-31",
  hourly = "cloudcover"
)
# }

Run the code above in your browser using DataLab