| get_era5 | R Documentation |
This function downloads ERA5 historical weather data from the Open-Meteo API
for specified locations and dates. It mimics the functionality of get_nasapower
by fetching weather variables and returning a daily-aggregated data frame.
It uses the Open-Meteo Archive API and aggregates hourly data to daily values
to ensure all variables (including relative humidity and dew point) are available.
get_era5(
data,
days_around,
date_col,
study_col = "study",
pars = c("temperature_2m", "relative_humidity_2m", "precipitation", "dewpoint_2m"),
models = NULL,
direction = "both"
)
data |
A data frame containing the input data, including columns for |
days_around |
An integer specifying the number of days before and after the date in the date column to download data. |
date_col |
A character string specifying the name of the date column in the data frame. |
study_col |
A character string specifying the name of the column containing the study identifier in the input data frame (default: "study"). |
pars |
A character vector specifying the weather variables to fetch from Open-Meteo.
These are mapped to |
models |
A character string specifying the reanalysis model(s) to use. If |
direction |
Character string specifying the direction of the date range relative to the reference date.
Options are "both" (default), "back", or "forth".
"back" retrieves data from |
Since the Open-Meteo Archive API daily endpoint does not provide all variables
(like mean relative humidity) directly, this function fetches hourly data and
performs the daily aggregation manually:
T2M: Mean of hourly temperature_2m
T2M_MAX: Max of hourly temperature_2m
T2M_MIN: Min of hourly temperature_2m
RH2M: Mean of hourly relative_humidity_2m
PRECTOTCORR: Sum of hourly precipitation
T2MDEW: Mean of hourly dewpoint_2m
A data frame (tibble) with daily weather data. Columns are named to match
nasapower conventions: date, T2M, T2M_MAX, T2M_MIN, RH2M, PRECTOTCORR,
T2MDEW, longitude, latitude, and study.
Other Disease modeling:
get_brdwgd(),
get_nasapower(),
windowpane()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.