get_weather_data: Load weather data via API

View source: R/get_weather_data.R

get_weather_dataR Documentation

Load weather data via API

Description

This function loads weather data which is used to forecast the mid-term load seasonalities. First the 20 most populated areas in the country are obtained from https://wft-geo-db.p.rapidapi.com . Then the closest weather stations of each area are identified and average daily temperature values are downloaded from https://meteostat.p.rapidapi.com for the provided time period. From this data a weighted daily average temperature based on population is calculated for the provided country.

Usage

get_weather_data(
  midterm_demand_data,
  api_key = "default",
  data_directory = tempdir()
)

Arguments

midterm_demand_data

Dataframe. The mid-term data series from decompose_load_data with added holidays resulting from the function add_holidays_mid_term.

api_key

Character. A valid API key from rapidapi that is subscribed to wft-geo-db and meteostat. If set to "default", one of the deposited keys will be used.

data_directory

The path to the directory where the data will be saved.

Value

A list containing the mid-term data and temperature data.

See Also

See function decompose_load_data for the generation of the mid-term series.

Examples

example_midterm_demand_and_weather_data <- get_weather_data(example_midterm_demand_data,
  api_key = "default"
)
head(example_midterm_demand_and_weather_data$demand)
head(example_midterm_demand_and_weather_data$temperature_data)

oRaklE documentation built on June 8, 2025, 12:41 p.m.