aemet_alerts: AEMET meteorological alerts

View source: R/aemet-alerts.R

aemet_alertsR Documentation

AEMET meteorological alerts

Description

[Experimental] Get current meteorological alerts.

Usage

aemet_alerts(
  ccaa = NULL,
  lang = c("es", "en"),
  verbose = FALSE,
  return_sf = FALSE,
  extract_metadata = FALSE,
  progress = TRUE
)

Arguments

ccaa

Character vector with names for autonomous communities or NULL to get all autonomous communities.

lang

Language of the results. It can be "es" (Spanish) or "en" (English).

verbose

Logical. If TRUE, provides information about the flow of information between the client and server.

return_sf

Logical. If TRUE, the function returns an sf spatial object. If FALSE (the default value), it returns a tibble. The sf package must be installed.

extract_metadata

Logical. If TRUE, the output is a tibble with the description of the fields. See also get_metadata_aemet().

progress

Logical. Displays a cli::cli_progress_bar() object. If verbose = TRUE, it will not be displayed.

Value

A tibble or a sf object.

Source

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 Also

aemet_alert_zones(). See also mapSpain::esp_codelist, mapSpain::esp_dict_region_code() to get the names of the autonomous communities.

AEMET data functions: aemet_alert_zones(), aemet_beaches(), aemet_daily_clim(), aemet_extremes_clim(), aemet_forecast_beaches(), aemet_forecast_daily(), aemet_forecast_fires(), aemet_last_obs(), aemet_monthly, aemet_normal, aemet_stations()

Examples


# 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"
    ))
}


climaemet documentation built on June 3, 2026, 5:07 p.m.