| Title: | Access and Visualize AEMET Weather and Climate Data |
|---|---|
| Description: | Provides access to meteorological observations, forecasts, alerts and climatology data from the Spanish Meteorological Agency (AEMET) through the 'AEMET OpenData' API <https://opendata.aemet.es/>. Includes tools for working with tabular and spatial data and for creating Walter-Lieth climate diagrams, warming stripes and wind roses. |
| Authors: | Manuel Pizarro [aut, cph] (ORCID: <https://orcid.org/0000-0002-6981-0154>), Diego Hernangómez [aut, cre] (ORCID: <https://orcid.org/0000-0001-8457-4658>), Gema Fernández-Avilés [aut] (ORCID: <https://orcid.org/0000-0001-5934-1916>), AEMET [cph] (ROR: <https://ror.org/04kxf1r09>) |
| Maintainer: | Diego Hernangómez <[email protected]> |
| License: | GPL-3 |
| Version: | 1.6.0 |
| Built: | 2026-06-19 16:37:07 UTC |
| Source: | https://github.com/rOpenSpain/climaemet |
Retrieves the AEMET geographical zones used for meteorological alerts.
aemet_alert_zones(verbose = FALSE, return_sf = FALSE)aemet_alert_zones(verbose = FALSE, return_sf = FALSE)
verbose |
A logical value. If |
return_sf |
A logical value. If |
The first result retrieved in each session is temporarily cached in
tempdir() to avoid unnecessary requests.
https://www.aemet.es/es/eltiempo/prediccion/avisos/ayuda. See also Annex 2 and Annex 3 documents, linked from that page.
Weather alerts:
aemet_alerts()
library(dplyr) alert_zones <- aemet_alert_zones() alert_zones # Cached during this R session. alert_zones2 <- aemet_alert_zones(verbose = TRUE) identical(alert_zones, alert_zones2) # Select and map alert zones. library(ggplot2) # Galicia. alert_zones_sf <- aemet_alert_zones(return_sf = TRUE) |> filter(COD_CCAA == "71") # Coast zones have codes ending in "C". alert_zones_sf$type <- ifelse(grepl("C$", alert_zones_sf$COD_Z), "Coast", "Mainland" ) ggplot(alert_zones_sf) + geom_sf(aes(fill = NOM_PROV)) + facet_wrap(~type) + scale_fill_brewer(palette = "Blues")library(dplyr) alert_zones <- aemet_alert_zones() alert_zones # Cached during this R session. alert_zones2 <- aemet_alert_zones(verbose = TRUE) identical(alert_zones, alert_zones2) # Select and map alert zones. library(ggplot2) # Galicia. alert_zones_sf <- aemet_alert_zones(return_sf = TRUE) |> filter(COD_CCAA == "71") # Coast zones have codes ending in "C". alert_zones_sf$type <- ifelse(grepl("C$", alert_zones_sf$COD_Z), "Coast", "Mainland" ) ggplot(alert_zones_sf) + geom_sf(aes(fill = NOM_PROV)) + facet_wrap(~type) + scale_fill_brewer(palette = "Blues")
Retrieves current meteorological
alerts issued by AEMET.
aemet_alerts( ccaa = NULL, lang = c("es", "en"), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_alerts( ccaa = NULL, lang = c("es", "en"), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
ccaa |
A character vector of autonomous community names or |
lang |
The language of the results, either |
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
https://www.aemet.es/en/eltiempo/prediccion/avisos and https://www.aemet.es/es/eltiempo/prediccion/avisos/ayuda for API status and alerts reference, including Annex 2 and Annex 3 documentation.
See mapSpain::esp_codelist and mapSpain::esp_dict_region_code() for
autonomous community names.
Weather alerts:
aemet_alert_zones()
# Display CCAA names. library(dplyr) aemet_alert_zones() |> select(NOM_CCAA) |> distinct() # Base map. cbasemap <- mapSpain::esp_get_ccaa(ccaa = c( "Galicia", "Asturias", "Cantabria", "Euskadi" )) # Alerts. alerts_north <- aemet_alerts( ccaa = c("Galicia", "Asturias", "Cantabria", "Euskadi"), return_sf = TRUE ) # Plot if there are alerts. if (inherits(alerts_north, "sf")) { library(ggplot2) library(lubridate) alerts_north$day <- date(alerts_north$effective) ggplot(alerts_north) + geom_sf(data = cbasemap, fill = "grey60") + geom_sf(aes(fill = `AEMET-Meteoalerta nivel`)) + geom_sf( data = cbasemap, fill = "transparent", color = "black", linewidth = 0.5 ) + facet_grid(vars(`AEMET-Meteoalerta fenomeno`), vars(day)) + scale_fill_manual(values = c( "amarillo" = "yellow", naranja = "orange", "rojo" = "red" )) }# Display CCAA names. library(dplyr) aemet_alert_zones() |> select(NOM_CCAA) |> distinct() # Base map. cbasemap <- mapSpain::esp_get_ccaa(ccaa = c( "Galicia", "Asturias", "Cantabria", "Euskadi" )) # Alerts. alerts_north <- aemet_alerts( ccaa = c("Galicia", "Asturias", "Cantabria", "Euskadi"), return_sf = TRUE ) # Plot if there are alerts. if (inherits(alerts_north, "sf")) { library(ggplot2) library(lubridate) alerts_north$day <- date(alerts_north$effective) ggplot(alerts_north) + geom_sf(data = cbasemap, fill = "grey60") + geom_sf(aes(fill = `AEMET-Meteoalerta nivel`)) + geom_sf( data = cbasemap, fill = "transparent", color = "black", linewidth = 0.5 ) + facet_grid(vars(`AEMET-Meteoalerta fenomeno`), vars(day)) + scale_fill_manual(values = c( "amarillo" = "yellow", naranja = "orange", "rojo" = "red" )) }
Stores an AEMET API key on your local machine so it can be used without including it in your code.
Alternatively, set the key for the current session with
Sys.setenv(AEMET_API_KEY = "Your_Key"), equivalent to install = FALSE.
To store it permanently, add AEMET_API_KEY = "Your_Key" to .Renviron,
equivalent to install = TRUE.
aemet_api_key(apikey, overwrite = FALSE, install = FALSE)aemet_api_key(apikey, overwrite = FALSE, install = FALSE)
apikey |
A character vector of AEMET API keys. Acquire a key at https://opendata.aemet.es/centrodedescargas/inicio. You can install multiple API keys at once. See Details. |
overwrite |
A logical value. If |
install |
A logical value. If |
You can pass multiple apikey values as a character vector, such as
c(api1, api2). In this case, multiple AEMET_API_KEY values are stored.
In each subsequent API call, climaemet chooses the API key with
the highest remaining quota.
This is useful when performing batch queries to avoid API throttling.
NULL, invisibly.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
To locate the stored API key, run
tools::R_user_dir("climaemet", "config").
AEMET API authentication:
aemet_detect_api_key()
# Do not run these examples. if (FALSE) { aemet_api_key("111111abc", install = TRUE) # Check it with: Sys.getenv("AEMET_API_KEY") } if (FALSE) { # Overwrite an existing key: aemet_api_key("222222abc", overwrite = TRUE, install = TRUE) # Check it with: Sys.getenv("AEMET_API_KEY") }# Do not run these examples. if (FALSE) { aemet_api_key("111111abc", install = TRUE) # Check it with: Sys.getenv("AEMET_API_KEY") } if (FALSE) { # Overwrite an existing key: aemet_api_key("222222abc", overwrite = TRUE, install = TRUE) # Check it with: Sys.getenv("AEMET_API_KEY") }
Retrieves the beaches available from the AEMET API.
aemet_beaches(verbose = FALSE, return_sf = FALSE)aemet_beaches(verbose = FALSE, return_sf = FALSE)
verbose |
A logical value. If |
return_sf |
A logical value. If |
The first result retrieved in each session is temporarily cached in
tempdir() to avoid unnecessary requests.
library(dplyr) beaches <- aemet_beaches() beaches # Cached during this R session. beaches2 <- aemet_beaches(verbose = TRUE) identical(beaches, beaches2) # Select and map beaches. library(ggplot2) library(mapSpain) # Alicante / Alacant. beaches_sf <- aemet_beaches(return_sf = TRUE) |> filter(ID_PROVINCIA == "03") prov <- mapSpain::esp_get_prov("Alicante") ggplot(prov) + geom_sf() + geom_sf( data = beaches_sf, shape = 4, size = 2.5, color = "blue" )library(dplyr) beaches <- aemet_beaches() beaches # Cached during this R session. beaches2 <- aemet_beaches(verbose = TRUE) identical(beaches, beaches2) # Select and map beaches. library(ggplot2) library(mapSpain) # Alicante / Alacant. beaches_sf <- aemet_beaches(return_sf = TRUE) |> filter(ID_PROVINCIA == "03") prov <- mapSpain::esp_get_prov("Alicante") ggplot(prov) + geom_sf() + geom_sf( data = beaches_sf, shape = 4, size = 2.5, color = "blue" )
Retrieves climatology values for one station or all available stations.
aemet_daily_period() and aemet_daily_period_all() are shortcuts for
aemet_daily_clim().
aemet_daily_clim( station = "all", start = Sys.Date() - 7, end = Sys.Date(), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_daily_period( station, start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_daily_period_all( start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_daily_clim( station = "all", start = Sys.Date() - 7, end = Sys.Date(), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_daily_period( station, start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_daily_period_all( start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
station |
A character vector of station identifiers (see
|
start, end
|
Character strings containing the start and end dates. See Details. |
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
For aemet_daily_clim(), start and end must be Date objects or
strings in YYYY-MM-DD format, such as "2020-12-31", that can be coerced
with as.Date(). For aemet_daily_period() and
aemet_daily_period_all(), they must be strings representing the years to
extract, such as "2018" and "2020".
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Climatology:
aemet_extremes_clim(),
aemet_monthly_clim(),
aemet_normal_clim()
library(dplyr) obs <- aemet_daily_clim(c("9434", "3195")) glimpse(obs) # Metadata. meta <- aemet_daily_clim(c("9434", "3195"), extract_metadata = TRUE) glimpse(meta$campos)library(dplyr) obs <- aemet_daily_clim(c("9434", "3195")) glimpse(obs) # Metadata. meta <- aemet_daily_clim(c("9434", "3195"), extract_metadata = TRUE) glimpse(meta$campos)
Detects whether an API key is available in the current session. An existing
environment variable is preserved. Otherwise, a key stored permanently with
aemet_api_key() is loaded.
aemet_detect_api_key(...) aemet_show_api_key(...)aemet_detect_api_key(...) aemet_show_api_key(...)
... |
Ignored. |
TRUE if an API key is available and FALSE otherwise.
aemet_show_api_key() displays stored API keys.
AEMET API authentication:
aemet_api_key()
aemet_detect_api_key() # Caution: This may reveal API keys. if (FALSE) { aemet_show_api_key() }aemet_detect_api_key() # Caution: This may reveal API keys. if (FALSE) { aemet_show_api_key() }
Retrieves recorded extreme values for one or more stations.
aemet_extremes_clim( station = NULL, parameter = "T", verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_extremes_clim( station = NULL, parameter = "T", verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
station |
A character vector of station identifiers. See
|
parameter |
A character string specifying the parameter to retrieve:
temperature ( |
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
A tibble or a sf object. If the function encounters a parsing error, it returns a list.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Climatology:
aemet_daily_clim(),
aemet_monthly_clim(),
aemet_normal_clim()
obs <- aemet_extremes_clim(c("9434", "3195")) dplyr::glimpse(obs)obs <- aemet_extremes_clim(c("9434", "3195")) dplyr::glimpse(obs)
Retrieves daily weather forecasts for one or more beaches. Use
aemet_beaches() to obtain beach codes.
aemet_forecast_beaches( x, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_forecast_beaches( x, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
x |
A character vector of beach codes to extract. See |
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
aemet_beaches() for beach codes.
Forecasts:
aemet_forecast_daily(),
aemet_forecast_fires(),
aemet_forecast_tidy()
# Forecast for beaches in Palma, Mallorca. library(dplyr) library(ggplot2) palma_b <- aemet_beaches() |> filter(ID_MUNICIPIO == "07040") forecast_b <- aemet_forecast_beaches(palma_b$ID_PLAYA) glimpse(forecast_b) ggplot(forecast_b) + geom_line(aes(fecha, tagua_valor1, color = nombre)) + facet_wrap(~nombre, ncol = 1) + labs( title = "Water temperature in beaches of Palma (ES)", subtitle = "3-day forecast", x = "Date", y = "Temperature (Celsius)", color = "Beach" )# Forecast for beaches in Palma, Mallorca. library(dplyr) library(ggplot2) palma_b <- aemet_beaches() |> filter(ID_MUNICIPIO == "07040") forecast_b <- aemet_forecast_beaches(palma_b$ID_PLAYA) glimpse(forecast_b) ggplot(forecast_b) + geom_line(aes(fecha, tagua_valor1, color = nombre)) + facet_wrap(~nombre, ncol = 1) + labs( title = "Water temperature in beaches of Palma (ES)", subtitle = "3-day forecast", x = "Date", y = "Temperature (Celsius)", color = "Beach" )
Retrieves daily or hourly weather forecasts for one or more municipalities.
aemet_forecast_daily( x, verbose = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_forecast_hourly( x, verbose = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_forecast_daily( x, verbose = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_forecast_hourly( x, verbose = FALSE, extract_metadata = FALSE, progress = TRUE )
x |
A character vector of municipality codes to extract.
For convenience, climaemet provides these data in the
aemet_munic dataset (see |
verbose |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
Forecasts provided by the AEMET API have a complex structure.
Although climaemet returns a tibble, each
forecast value is provided as a nested tibble.
The aemet_forecast_tidy() helper can unnest these values and provide a
single unnested tibble for the requested variable.
If extract_metadata = TRUE, the function returns a simple
tibble describing each forecast field.
A nested tibble. Forecast values can be
extracted with aemet_forecast_tidy(). See also Details.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
aemet_munic for municipality codes and mapSpain for
working with sf objects of municipalities (see
mapSpain::esp_get_munic() and Examples).
Forecasts:
aemet_forecast_beaches(),
aemet_forecast_fires(),
aemet_forecast_tidy()
# Select cities. data("aemet_munic") library(dplyr) munis <- aemet_munic |> filter(municipio_nombre %in% c("Santiago de Compostela", "Lugo")) |> pull(municipio) daily <- aemet_forecast_daily(munis) # Metadata. meta <- aemet_forecast_daily(munis, extract_metadata = TRUE) glimpse(meta$campos) # Variables available. aemet_forecast_vars_available(daily) # This is nested. daily |> select(municipio, fecha, nombre, temperatura) # Select and unnest. daily_temp <- aemet_forecast_tidy(daily, "temperatura") # This is not nested. daily_temp # Wrangle and plot. daily_temp_end <- daily_temp |> select( elaborado, fecha, municipio, nombre, temperatura_minima, temperatura_maxima ) |> tidyr::pivot_longer(cols = contains("temperatura")) # Plot. library(ggplot2) ggplot(daily_temp_end) + geom_line(aes(fecha, value, color = name)) + facet_wrap(~nombre, ncol = 1) + scale_color_manual( values = c("red", "blue"), labels = c("max", "min") ) + scale_x_date( labels = scales::label_date_short(), breaks = "day" ) + scale_y_continuous( labels = scales::label_comma(suffix = "º") ) + theme_minimal() + labs( x = "", y = "", color = "", title = "Forecast: 7-day temperature", subtitle = paste( "Forecast produced on", format(daily_temp_end$elaborado[1], usetz = TRUE) ) ) # Spatial data. library(mapSpain) library(sf) lugo_sf <- esp_get_munic(munic = "Lugo") |> select(LAU_CODE) daily_temp_end_lugo_sf <- daily_temp_end |> filter(nombre == "Lugo" & name == "temperatura_maxima") |> # Join by LAU_CODE. left_join(lugo_sf, by = c("municipio" = "LAU_CODE")) |> st_as_sf() ggplot(daily_temp_end_lugo_sf) + geom_sf(aes(fill = value)) + facet_wrap(~fecha) + scale_fill_gradientn( colors = c("blue", "red"), guide = guide_legend() ) + labs( main = "Forecast: 7-day max temperature", subtitle = "Lugo, ES" )# Select cities. data("aemet_munic") library(dplyr) munis <- aemet_munic |> filter(municipio_nombre %in% c("Santiago de Compostela", "Lugo")) |> pull(municipio) daily <- aemet_forecast_daily(munis) # Metadata. meta <- aemet_forecast_daily(munis, extract_metadata = TRUE) glimpse(meta$campos) # Variables available. aemet_forecast_vars_available(daily) # This is nested. daily |> select(municipio, fecha, nombre, temperatura) # Select and unnest. daily_temp <- aemet_forecast_tidy(daily, "temperatura") # This is not nested. daily_temp # Wrangle and plot. daily_temp_end <- daily_temp |> select( elaborado, fecha, municipio, nombre, temperatura_minima, temperatura_maxima ) |> tidyr::pivot_longer(cols = contains("temperatura")) # Plot. library(ggplot2) ggplot(daily_temp_end) + geom_line(aes(fecha, value, color = name)) + facet_wrap(~nombre, ncol = 1) + scale_color_manual( values = c("red", "blue"), labels = c("max", "min") ) + scale_x_date( labels = scales::label_date_short(), breaks = "day" ) + scale_y_continuous( labels = scales::label_comma(suffix = "º") ) + theme_minimal() + labs( x = "", y = "", color = "", title = "Forecast: 7-day temperature", subtitle = paste( "Forecast produced on", format(daily_temp_end$elaborado[1], usetz = TRUE) ) ) # Spatial data. library(mapSpain) library(sf) lugo_sf <- esp_get_munic(munic = "Lugo") |> select(LAU_CODE) daily_temp_end_lugo_sf <- daily_temp_end |> filter(nombre == "Lugo" & name == "temperatura_maxima") |> # Join by LAU_CODE. left_join(lugo_sf, by = c("municipio" = "LAU_CODE")) |> st_as_sf() ggplot(daily_temp_end_lugo_sf) + geom_sf(aes(fill = value)) + facet_wrap(~fecha) + scale_fill_gradientn( colors = c("blue", "red"), guide = guide_legend() ) + labs( main = "Forecast: 7-day max temperature", subtitle = "Lugo, ES" )
Retrieves daily wildfire risk levels as either tabular data or a
SpatRaster.
aemet_forecast_fires( area = c("p", "c"), verbose = FALSE, extract_metadata = FALSE )aemet_forecast_fires( area = c("p", "c"), verbose = FALSE, extract_metadata = FALSE )
area |
A character string specifying the forecast area: |
verbose |
A logical value. If |
extract_metadata |
A logical value. If |
The SpatRaster provides six factor() levels: "1" for very low risk,
"2" for low risk, "3" for moderate risk, "4" for high risk, "5"
for very high risk and "6" for extreme risk.
The resulting object has several layers, each representing one of the next
seven forecast days. It also has additional attributes provided by the
terra package, such as terra::time() and terra::coltab().
A tibble or a SpatRaster.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
https://www.aemet.es/en/eltiempo/prediccion/incendios.
Forecasts:
aemet_forecast_beaches(),
aemet_forecast_daily(),
aemet_forecast_tidy()
aemet_forecast_fires(extract_metadata = TRUE) # Extract alerts. alerts <- aemet_forecast_fires() alerts # Plot the raster. library(terra) plot(alerts, all_levels = TRUE) # Zoom in on an area. cyl <- mapSpain::esp_get_ccaa("Castilla y Leon", epsg = 4326) # Convert to a SpatVector. cyl <- vect(cyl) fires_cyl <- crop(alerts, cyl) title <- names(fires_cyl)[1] plot(fires_cyl[[1]], main = title, all_levels = TRUE) plot(cyl, add = TRUE)aemet_forecast_fires(extract_metadata = TRUE) # Extract alerts. alerts <- aemet_forecast_fires() alerts # Plot the raster. library(terra) plot(alerts, all_levels = TRUE) # Zoom in on an area. cyl <- mapSpain::esp_get_ccaa("Castilla y Leon", epsg = 4326) # Convert to a SpatVector. cyl <- vect(cyl) fires_cyl <- crop(alerts, cyl) title <- names(fires_cyl)[1] plot(fires_cyl[[1]], main = title, all_levels = TRUE) plot(cyl, add = TRUE)
aemet_forecast_vars_available() lists the variables in output from
aemet_forecast_daily() or aemet_forecast_hourly().
aemet_forecast_tidy() extracts the forecast for var as a
tibble.
aemet_forecast_tidy(x, var) aemet_forecast_vars_available(x)aemet_forecast_tidy(x, var) aemet_forecast_vars_available(x)
x |
A dataset extracted with |
var |
The name of the forecast variable to extract. |
A character vector from aemet_forecast_vars_available() or a
tibble from aemet_forecast_tidy().
Forecasts:
aemet_forecast_beaches(),
aemet_forecast_daily(),
aemet_forecast_fires()
# Hourly values. hourly <- aemet_forecast_hourly(c("15030", "28079")) # Variables available. aemet_forecast_vars_available(hourly) # Get temperature. temp <- aemet_forecast_tidy(hourly, "temperatura") library(dplyr) # Create a forecast time and adjust its time zone. temp_end <- temp |> mutate( forecast_time = lubridate::force_tz( as.POSIXct(fecha) + hora, tz = "Europe/Madrid" ) ) # Add sunset and sunrise. suns <- temp_end |> select(nombre, fecha, orto, ocaso) |> distinct_all() |> group_by(nombre) |> mutate( ocaso_end = lubridate::force_tz( as.POSIXct(fecha) + ocaso, tz = "Europe/Madrid" ), orto_end = lubridate::force_tz( as.POSIXct(fecha) + orto, tz = "Europe/Madrid" ), orto_lead = lead(orto_end) ) |> tidyr::drop_na() # Plot. library(ggplot2) ggplot(temp_end) + geom_rect(data = suns, aes( xmin = ocaso_end, xmax = orto_lead, ymin = min(temp_end$temperatura), ymax = max(temp_end$temperatura) ), alpha = 0.4) + geom_line(aes(forecast_time, temperatura), color = "blue4") + facet_wrap(~nombre, nrow = 2) + scale_x_datetime(labels = scales::label_date_short()) + scale_y_continuous(labels = scales::label_number(suffix = "º")) + labs( x = "", y = "", title = "Forecast: Temperature", subtitle = paste("Forecast produced on", format(temp_end$elaborado[1], usetz = TRUE )) )# Hourly values. hourly <- aemet_forecast_hourly(c("15030", "28079")) # Variables available. aemet_forecast_vars_available(hourly) # Get temperature. temp <- aemet_forecast_tidy(hourly, "temperatura") library(dplyr) # Create a forecast time and adjust its time zone. temp_end <- temp |> mutate( forecast_time = lubridate::force_tz( as.POSIXct(fecha) + hora, tz = "Europe/Madrid" ) ) # Add sunset and sunrise. suns <- temp_end |> select(nombre, fecha, orto, ocaso) |> distinct_all() |> group_by(nombre) |> mutate( ocaso_end = lubridate::force_tz( as.POSIXct(fecha) + ocaso, tz = "Europe/Madrid" ), orto_end = lubridate::force_tz( as.POSIXct(fecha) + orto, tz = "Europe/Madrid" ), orto_lead = lead(orto_end) ) |> tidyr::drop_na() # Plot. library(ggplot2) ggplot(temp_end) + geom_rect(data = suns, aes( xmin = ocaso_end, xmax = orto_lead, ymin = min(temp_end$temperatura), ymax = max(temp_end$temperatura) ), alpha = 0.4) + geom_line(aes(forecast_time, temperatura), color = "blue4") + facet_wrap(~nombre, nrow = 2) + scale_x_datetime(labels = scales::label_date_short()) + scale_y_continuous(labels = scales::label_number(suffix = "º")) + labs( x = "", y = "", title = "Forecast: Temperature", subtitle = paste("Forecast produced on", format(temp_end$elaborado[1], usetz = TRUE )) )
Retrieves the latest observations for one or more weather stations.
aemet_last_obs( station = "all", verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_last_obs( station = "all", verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
station |
A character vector of station identifiers (see
|
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
obs <- aemet_last_obs(c("9434", "3195")) dplyr::glimpse(obs)obs <- aemet_last_obs(c("9434", "3195")) dplyr::glimpse(obs)
Retrieves monthly or annual climatology values for one or more stations.
aemet_monthly_period() and aemet_monthly_period_all() allow requests
that span several years.
aemet_monthly_clim( station = NULL, year = as.integer(format(Sys.Date(), "%Y")), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_monthly_period( station = NULL, start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_monthly_period_all( start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_monthly_clim( station = NULL, year = as.integer(format(Sys.Date(), "%Y")), verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_monthly_period( station = NULL, start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_monthly_period_all( start = as.integer(format(Sys.Date(), "%Y")), end = start, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
station |
A character vector of station identifiers. See
|
year |
A numeric year in |
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
start |
A numeric value specifying the start year in |
end |
A numeric value specifying the end year in |
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Climatology:
aemet_daily_clim(),
aemet_extremes_clim(),
aemet_normal_clim()
obs <- aemet_monthly_clim(station = c("9434", "3195"), year = 2000) dplyr::glimpse(obs)obs <- aemet_monthly_clim(station = c("9434", "3195"), year = 2000) dplyr::glimpse(obs)
A tibble containing all municipalities of Spain as defined by the INE (Instituto Nacional de Estadistica) as of January 2025.
A tibble with 8,132 rows and fields:
INE code of the municipality.
INE name of the municipality.
INE code of the province.
INE name of the province.
INE code of the autonomous community.
INE name of the autonomous community.
INE municipality codes by province: https://www.ine.es/daco/daco42/codmun/diccionario25.xlsx.
aemet_forecast_daily(),
aemet_forecast_hourly().
data(aemet_munic) aemet_municdata(aemet_munic) aemet_munic
Retrieves climatological normal values for a station or for all stations
with aemet_normal_clim_all(). The standard normal period is 1981–2010.
aemet_normal_clim( station = NULL, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_normal_clim_all( verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )aemet_normal_clim( station = NULL, verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE ) aemet_normal_clim_all( verbose = FALSE, return_sf = FALSE, extract_metadata = FALSE, progress = TRUE )
station |
A character vector of station identifiers (see
|
verbose |
A logical value. If |
return_sf |
A logical value. If |
extract_metadata |
A logical value. If |
progress |
A logical value. If |
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Code modified from project https://github.com/SevillaR/aemet.
Climatology:
aemet_daily_clim(),
aemet_extremes_clim(),
aemet_monthly_clim()
obs <- aemet_normal_clim(c("9434", "3195")) dplyr::glimpse(obs)obs <- aemet_normal_clim(c("9434", "3195")) dplyr::glimpse(obs)
Retrieves the weather stations available from the AEMET API.
aemet_stations(verbose = FALSE, return_sf = FALSE)aemet_stations(verbose = FALSE, return_sf = FALSE)
verbose |
A logical value. If |
return_sf |
A logical value. If |
The first result retrieved in each session is temporarily cached in
tempdir() to avoid unnecessary requests.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Code modified from project https://github.com/SevillaR/aemet.
library(dplyr) stations <- aemet_stations() stations # Cached during this R session. stations2 <- aemet_stations(verbose = TRUE) identical(stations, stations2)library(dplyr) stations <- aemet_stations() stations # Cached during this R session. stations2 <- aemet_stations(verbose = TRUE) identical(stations, stations2)
Climatological normal data for Zaragoza Airport (1981–2010). This example dataset is used to create Walter-Lieth climate diagrams.
A data frame with four rows and 12 columns. Columns 1 through 12
represent months from January through December. Rows contain:
p_mes_md: precipitation (mm).
tm_max_md: maximum temperature (Celsius).
tm_min_md: minimum temperature (Celsius).
ta_min_min: absolute monthly minimum temperature (Celsius).
AEMET.
ggclimat_walter_lieth(), climatogram_period(),
climatogram_normal().
data(climaemet_9434_climatogram)data(climaemet_9434_climatogram)
Yearly observations of average temperature for Zaragoza Airport (1950–2020). This is an example dataset.
A tibble with columns:
Year of reference.
Identifier of the station.
Average temperature (Celsius).
AEMET.
climatestripes_station(), ggstripes().
data(climaemet_9434_temp)data(climaemet_9434_temp)
Daily observations of wind speed and direction for Zaragoza Airport (2000–2020). This is an example dataset.
A tibble with columns:
Date of observation.
Wind direction (0-360 degrees).
Average wind speed (km/h).
AEMET.
windrose_days(), windrose_period(), ggwindrose().
data(climaemet_9434_wind)data(climaemet_9434_wind)
Opens the NEWS file for climaemet.
climaemet_news()climaemet_news()
NULL, invisibly. This function is called for its side effect.
## Not run: climaemet_news() ## End(Not run)## Not run: climaemet_news() ## End(Not run)
Plots warming stripes for a weather station over a specified period.
climatestripes_station( station, start = 1950, end = 2020, with_labels = "yes", verbose = FALSE, ... )climatestripes_station( station, start = 1950, end = 2020, with_labels = "yes", verbose = FALSE, ... )
station |
A character vector of station identifiers. See
|
start |
A numeric value specifying the start year in |
end |
A numeric value specifying the end year in |
with_labels |
A character string indicating whether to display plot
labels, either |
verbose |
A logical value. If |
... |
Arguments passed on to
|
A ggplot2 object. See help("ggplot2").
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
Professor Ed Hawkins of the University of Reading developed the "warming stripes" concept to communicate climate change risks as simply as possible. For more details, see ShowYourStripes.
Warming stripes:
ggstripes()
# Do not run this example. if (FALSE) { # Downloading data may take a few minutes. climatestripes_station( "9434", start = 2020, end = 2024, with_labels = "yes", col_pal = "Inferno" ) }# Do not run this example. if (FALSE) { # Downloading data may take a few minutes. climatestripes_station( "9434", start = 2020, end = 2024, with_labels = "yes", col_pal = "Inferno" ) }
Plots a Walter-Lieth climate diagram from climatological normal values for a station. The diagram summarizes local climate conditions for 1981–2010.
climatogram_normal( station, labels = "en", verbose = FALSE, ggplot2 = TRUE, ... )climatogram_normal( station, labels = "en", verbose = FALSE, ggplot2 = TRUE, ... )
station |
A character vector of station identifiers. See
|
labels |
A character string specifying the language for the x-axis
month labels, such as |
verbose |
A logical value. If |
ggplot2 |
A logical value. If |
... |
Further arguments passed to
|
A plot.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
The implementation is based on climatol.
Walter, H. K., Harnickell, E., Lieth, F. H. H. and Rehder, H. (1967). Klimadiagramm-weltatlas. Jena: Fischer.
Guijarro J. A. (2023). climatol: Climate Tools (Series Homogenization and Derived Products). R package version 4.0.0, https://climatol.eu.
Walter-Lieth climate diagrams:
climatogram_period(),
ggclimat_walter_lieth()
climatogram_normal("9434")climatogram_normal("9434")
Plots a Walter-Lieth climate diagram from monthly climatology values for a station over a specified time period.
climatogram_period( station = NULL, start = 1990, end = 2020, labels = "en", verbose = FALSE, ggplot2 = TRUE, ... )climatogram_period( station = NULL, start = 1990, end = 2020, labels = "en", verbose = FALSE, ggplot2 = TRUE, ... )
station |
A character vector of station identifiers. See
|
start |
A numeric value specifying the start year in |
end |
A numeric value specifying the end year in |
labels |
A character string specifying the language for the x-axis
month labels, such as |
verbose |
A logical value. If |
ggplot2 |
A logical value. If |
... |
Further arguments passed to
|
A plot.
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
The implementation is based on climatol.
Walter, H. K., Harnickell, E., Lieth, F. H. H. and Rehder, H. (1967). Klimadiagramm-weltatlas. Jena: Fischer.
Guijarro J. A. (2023). climatol: Climate Tools (Series Homogenization and Derived Products). R package version 4.0.0, https://climatol.eu.
Walter-Lieth climate diagrams:
climatogram_normal(),
ggclimat_walter_lieth()
climatogram_period("9434", start = 2015, end = 2020, labels = "en")climatogram_period("9434", start = 2015, end = 2020, labels = "en")
Converts degrees, minutes and seconds to decimal degrees.
dms2decdegrees(input = NULL) dms2decdegrees_2(input = NULL)dms2decdegrees(input = NULL) dms2decdegrees_2(input = NULL)
input |
A character string containing DMS coordinates. |
A numeric value.
Code for dms2decdegrees() was modified from the project at
https://github.com/SevillaR/aemet.
dms2decdegrees("055245W") dms2decdegrees_2("-3º 40' 37\"")dms2decdegrees("055245W") dms2decdegrees_2("-3º 40' 37\"")
Returns the first or last calendar day of a year.
first_day_of_year(year = NULL) last_day_of_year(year = NULL)first_day_of_year(year = NULL) last_day_of_year(year = NULL)
year |
A numeric year in |
A character string containing a date in YYYY-MM-DD format.
first_day_of_year(2000) last_day_of_year(2020)first_day_of_year(2000) last_day_of_year(2020)
Retrieves data and metadata from AEMET and converts JSON responses to a tibble when possible.
get_data_aemet(apidest, verbose = FALSE) get_metadata_aemet(apidest, verbose = FALSE)get_data_aemet(apidest, verbose = FALSE) get_metadata_aemet(apidest, verbose = FALSE)
apidest |
A character string containing the destination URL. See https://opendata.aemet.es/dist/index.html. |
verbose |
A logical value. If |
A tibble (if possible) or the results of the query as
provided by httr2::resp_body_raw() or httr2::resp_body_string().
https://opendata.aemet.es/dist/index.html.
See examples of how to use these functions in
vignette("extending-climaemet", package = "climaemet").
# Run only when AEMET_API_KEY is detected. url <- "/api/valores/climatologicos/inventarioestaciones/todasestaciones" get_data_aemet(url) # Metadata. get_metadata_aemet(url) # Get data from any API endpoint. # Plain text. plain <- get_data_aemet("/api/prediccion/nacional/hoy") cat(plain) # An image. image <- get_data_aemet("/api/mapasygraficos/analisis") # Write and read. tmp <- tempfile(fileext = ".gif") writeBin(image, tmp) gganimate::gif_file(tmp)# Run only when AEMET_API_KEY is detected. url <- "/api/valores/climatologicos/inventarioestaciones/todasestaciones" get_data_aemet(url) # Metadata. get_metadata_aemet(url) # Get data from any API endpoint. # Plain text. plain <- get_data_aemet("/api/prediccion/nacional/hoy") cat(plain) # An image. image <- get_data_aemet("/api/mapasygraficos/analisis") # Write and read. tmp <- tempfile(fileext = ".gif") writeBin(image, tmp) gganimate::gif_file(tmp)
Plots a Walter-Lieth climate diagram for a station. This function is an
updated version of climatol::diagwl() by José A. Guijarro.
ggclimat_walter_lieth( dat, est = "", alt = NA, per = NA, mlab = "es", pcol = "#002F70", tcol = "#ff0000", pfcol = "#9BAEE2", sfcol = "#3C6FC4", shem = FALSE, p3line = FALSE, ... )ggclimat_walter_lieth( dat, est = "", alt = NA, per = NA, mlab = "es", pcol = "#002F70", tcol = "#ff0000", pfcol = "#9BAEE2", sfcol = "#3C6FC4", shem = FALSE, p3line = FALSE, ... )
dat |
Monthly climatology data from which to create the diagram. |
est |
Name of the climatological station. |
alt |
Altitude of the climatological station. |
per |
Period used to compute the averages. |
mlab |
Month labels for the x-axis. Use a two-letter language code,
such as |
pcol |
Color for precipitation. |
tcol |
Color for temperature. |
pfcol |
Fill color for probable frosts. |
sfcol |
Fill color for sure frosts. |
shem |
Set to |
p3line |
Set to |
... |
Further graphic arguments. |
See the details in climatol::diagwl().
Climatology data must be passed as a 4 by 12 matrix or data frame of monthly data from January to December. Rows must contain mean precipitation, mean maximum daily temperature, mean minimum daily temperature and absolute monthly minimum temperature, in that order.
See climaemet_9434_climatogram for a sample dataset.
A ggplot2 object. See help("ggplot2").
Walter, H. K., Harnickell, E., Lieth, F. H. H. and Rehder, H. (1967). Klimadiagramm-weltatlas. Jena: Fischer.
Guijarro J. A. (2023). climatol: Climate Tools (Series Homogenization and Derived Products). R package version 4.0.0, https://climatol.eu.
climatol::diagwl() and readr::locale().
Walter-Lieth climate diagrams:
climatogram_normal(),
climatogram_period()
library(ggplot2) wl <- ggclimat_walter_lieth( climaemet::climaemet_9434_climatogram, alt = "249", per = "1981-2010", est = "Zaragoza Airport" ) wl # Since it is a ggplot object, we can modify it. wl + theme( plot.background = element_rect(fill = "grey80"), panel.background = element_rect(fill = "grey70"), axis.text.y.left = element_text( colour = "black", face = "italic" ), axis.text.y.right = element_text( colour = "black", face = "bold" ) )library(ggplot2) wl <- ggclimat_walter_lieth( climaemet::climaemet_9434_climatogram, alt = "249", per = "1981-2010", est = "Zaragoza Airport" ) wl # Since it is a ggplot object, we can modify it. wl + theme( plot.background = element_rect(fill = "grey80"), panel.background = element_rect(fill = "grey70"), axis.text.y.left = element_text( colour = "black", face = "italic" ), axis.text.y.right = element_text( colour = "black", face = "bold" ) )
Plots warming stripes with ggplot2. These graphics represent temperature change at a location over at least 70 years. Each stripe shows the annual average temperature at that station.
ggstripes( data, plot_type = "stripes", plot_title = "", n_temp = 11, col_pal = "RdBu", ... )ggstripes( data, plot_type = "stripes", plot_title = "", n_temp = 11, col_pal = "RdBu", ... )
data |
A data frame with date ( |
plot_type |
A character string specifying the plot type:
|
plot_title |
A character string for the plot title. |
n_temp |
The number of colors in the palette. Defaults to |
col_pal |
A character string specifying the
|
... |
Further arguments passed to |
A ggplot2 object. See help("ggplot2").
Professor Ed Hawkins of the University of Reading developed the "warming stripes" concept to communicate climate change risks as simply as possible. For more details, see ShowYourStripes.
ggplot2::theme() for additional
arguments to ggstripes() and climaemet_9434_temp.
Warming stripes:
climatestripes_station()
library(ggplot2) data <- climaemet::climaemet_9434_temp ggstripes(data, plot_title = "Zaragoza Airport") + labs(subtitle = "(1950-2020)") ggstripes(data, plot_title = "Zaragoza Airport", plot_type = "trend") + labs(subtitle = "(1950-2020)")library(ggplot2) data <- climaemet::climaemet_9434_temp ggstripes(data, plot_title = "Zaragoza Airport") + labs(subtitle = "(1950-2020)") ggstripes(data, plot_title = "Zaragoza Airport", plot_type = "trend") + labs(subtitle = "(1950-2020)")
Plots a wind rose showing wind speed and direction with ggplot2.
ggwindrose( speed, direction, n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, facet = NULL, plot_title = "", stack_reverse = FALSE, ... )ggwindrose( speed, direction, n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, facet = NULL, plot_title = "", stack_reverse = FALSE, ... )
speed |
A numeric vector of wind speeds. |
direction |
A numeric vector of wind directions. |
n_directions |
The number of direction bins to plot
(petals on the rose). Valid values are |
n_speeds |
The number of equally spaced wind speed bins to plot when
|
speed_cuts |
A numeric vector with the cut points for the wind speed
intervals, or |
col_pal |
A character string specifying the
|
legend_title |
A character string or expression for the legend title. |
calm_wind |
The upper wind speed limit considered calm. Defaults to |
n_col |
The number of plot columns. Defaults to |
facet |
A character or factor vector of facets used to plot wind roses. |
plot_title |
A character string for the plot title. |
stack_reverse |
A logical value. If |
... |
Further arguments (ignored). |
A ggplot2 object. See help("ggplot2").
ggplot2::theme() for additional arguments to pass to
ggwindrose() and climaemet_9434_wind.
Wind roses:
windrose_days(),
windrose_period()
library(ggplot2) speed <- climaemet::climaemet_9434_wind$velmedia direction <- climaemet::climaemet_9434_wind$dir rose <- ggwindrose( speed = speed, direction = direction, speed_cuts = seq(0, 16, 4), legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, plot_title = "Zaragoza Airport" ) rose + labs( subtitle = "2000-2020", caption = "Source: AEMET" ) # Reverse the stack. ggwindrose( speed = speed, direction = direction, speed_cuts = seq(0, 16, 4), legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, plot_title = "Zaragoza Airport", stack_reverse = TRUE ) + labs( subtitle = "2000-2020", caption = "Source: AEMET" )library(ggplot2) speed <- climaemet::climaemet_9434_wind$velmedia direction <- climaemet::climaemet_9434_wind$dir rose <- ggwindrose( speed = speed, direction = direction, speed_cuts = seq(0, 16, 4), legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, plot_title = "Zaragoza Airport" ) rose + labs( subtitle = "2000-2020", caption = "Source: AEMET" ) # Reverse the stack. ggwindrose( speed = speed, direction = direction, speed_cuts = seq(0, 16, 4), legend_title = "Wind speed (m/s)", calm_wind = 0, n_col = 1, plot_title = "Zaragoza Airport", stack_reverse = TRUE ) + labs( subtitle = "2000-2020", caption = "Source: AEMET" )
Plots a wind rose showing wind speed and direction at a station over a period of days.
windrose_days( station, start = "2000-12-01", end = "2000-12-31", n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", calm_wind = 0, legend_title = "Wind speed (m/s)", verbose = FALSE )windrose_days( station, start = "2000-12-01", end = "2000-12-31", n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", calm_wind = 0, legend_title = "Wind speed (m/s)", verbose = FALSE )
station |
A character vector of station identifiers (see
|
start |
A character string containing the start date in |
end |
A character string containing the end date in |
n_directions |
The number of direction bins to plot
(petals on the rose). Valid values are |
n_speeds |
The number of equally spaced wind speed bins to plot when
|
speed_cuts |
A numeric vector with the cut points for the wind speed
intervals, or |
col_pal |
A character string specifying the
|
calm_wind |
The upper wind speed limit considered calm. Defaults to |
legend_title |
A character string or expression for the legend title. |
verbose |
A logical value. If |
A ggplot2 object. See help("ggplot2").
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
aemet_daily_clim() and climaemet_9434_wind.
Wind roses:
ggwindrose(),
windrose_period()
windrose_days("9434", start = "2000-12-01", end = "2000-12-31", speed_cuts = 4 )windrose_days("9434", start = "2000-12-01", end = "2000-12-31", speed_cuts = 4 )
Plots a wind rose showing wind speed and direction at a station over a time period.
windrose_period( station, start = 2000, end = 2010, n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", calm_wind = 0, legend_title = "Wind speed (m/s)", verbose = FALSE )windrose_period( station, start = 2000, end = 2010, n_directions = 8, n_speeds = 5, speed_cuts = NA, col_pal = "GnBu", calm_wind = 0, legend_title = "Wind speed (m/s)", verbose = FALSE )
station |
A character vector of station identifiers. See
|
start |
A numeric value specifying the start year in |
end |
A numeric value specifying the end year in |
n_directions |
The number of direction bins to plot
(petals on the rose). Valid values are |
n_speeds |
The number of equally spaced wind speed bins to plot when
|
speed_cuts |
A numeric vector with the cut points for the wind speed
intervals, or |
col_pal |
A character string specifying the
|
calm_wind |
The upper wind speed limit considered calm. Defaults to |
legend_title |
A character string or expression for the legend title. |
verbose |
A logical value. If |
A ggplot2 object. See help("ggplot2").
Queries to the AEMET OpenData API require an API key. Use aemet_api_key()
to set it globally. Query timeout can be controlled with
options(climaemet_timeout = 60) (default value). See
httr2::req_timeout() for details.
aemet_daily_period() and climaemet_9434_wind.
Wind roses:
ggwindrose(),
windrose_days()
# Do not run this example. if (FALSE) { # Downloading data may take a few minutes. windrose_period("9434", start = 2000, end = 2010, speed_cuts = 4 ) }# Do not run this example. if (FALSE) { # Downloading data may take a few minutes. windrose_period("9434", start = 2000, end = 2010, speed_cuts = 4 ) }