Retrieves climatology values for one station or all available stations.
aemet_daily_period() and aemet_daily_period_all() are shortcuts for
aemet_daily_clim().
Usage
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
)Arguments
- station
A character vector of station identifiers (see
aemet_stations()) or"all"for all stations.- start, end
Character strings containing the start and end dates. See Details.
- verbose
A logical value. If
TRUE, displays information about the exchange between the client and server.- return_sf
A logical value. If
TRUE, the function returns ansfspatial object. IfFALSE(the default), it returns a tibble. The sf package must be installed.- extract_metadata
A logical value. If
TRUE, returns a tibble describing the response fields. Seeget_metadata_aemet().- progress
A logical value. If
TRUE, displays acli::cli_progress_bar()unlessverbose = TRUE.
Details
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".
API key
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.
See also
Climatology:
aemet_extremes_clim(),
aemet_monthly_clim(),
aemet_normal_clim()
Examples
library(dplyr)
obs <- aemet_daily_clim(c("9434", "3195"))
glimpse(obs)
#> Rows: 8
#> Columns: 27
#> $ fecha <date> 2026-06-17, 2026-06-18, 2026-06-19, 2026-06-20, 2026-06-1…
#> $ indicativo <chr> "9434", "9434", "9434", "9434", "3195", "3195", "3195", "3…
#> $ nombre <chr> "ZARAGOZA, AEROPUERTO", "ZARAGOZA, AEROPUERTO", "ZARAGOZA,…
#> $ provincia <chr> "ZARAGOZA", "ZARAGOZA", "ZARAGOZA", "ZARAGOZA", "MADRID", …
#> $ altitud <dbl> 249, 249, 249, 249, 667, 667, 667, 667
#> $ tmed <dbl> 29.6, 28.6, 28.9, 30.5, 28.4, 28.6, 28.6, 30.2
#> $ prec <dbl> 0.0, 0.0, 0.0, 2.8, 0.0, 0.0, 0.0, 0.0
#> $ tmin <dbl> 21.7, 20.7, 20.9, 22.9, 21.9, 22.2, 22.9, 23.8
#> $ horatmin <time> 05:00:00, 04:50:00, 05:00:00, 05:10:00, 06:00:00, 06:20:00…
#> $ tmax <dbl> 37.5, 36.6, 36.9, 38.1, 34.9, 34.9, 34.4, 36.7
#> $ horatmax <time> 16:00:00, 15:00:00, 15:10:00, 14:30:00, 14:30:00, 14:50:00…
#> $ dir <dbl> 13, 13, 12, 28, 13, 15, 12, 16
#> $ velmedia <dbl> 2.8, 5.6, 5.8, 4.2, 2.5, 3.1, 1.7, 3.1
#> $ racha <dbl> 9.7, 12.5, 12.5, 17.8, 9.2, 8.1, 12.2, 12.2
#> $ horaracha <time> 19:30:00, 18:20:00, 15:40:00, 17:10:00, 23:10:00, 13:20:00…
#> $ sol <dbl> 14.2, 13.7, 12.2, 9.7, NA, NA, NA, NA
#> $ presMax <dbl> 990.0, 988.7, 988.1, 991.3, 944.5, 943.3, 940.4, 944.1
#> $ horaPresMax <chr> "Varias", "05", "23", "24", "08", "02", "08", "23"
#> $ presMin <dbl> 985.4, 983.3, 983.3, 986.5, 940.3, 937.8, 937.0, 939.4
#> $ horaPresMin <chr> "18", "17", "16", "19", "18", "Varias", "18", "16"
#> $ hrMedia <dbl> 26, 24, 27, 38, 29, 25, 28, 36
#> $ hrMax <dbl> 55, 57, 51, 56, 51, 38, 43, 57
#> $ horaHrMax <time> 05:20:00, 04:40:00, 05:00:00, 17:00:00, 06:20:00, 06:40:00…
#> $ hrMin <dbl> 11, 13, 16, 20, 16, 15, 16, 21
#> $ horaHrMin <chr> "16:10", "Varias", "14:40", "15:30", "14:30", "Varias", "…
#> $ pintMax <dbl> 0, 0, 0, 12, 0, 0, 0, 0
#> $ horaPIntMax <time> NA, NA, NA, 16:27:00, NA, NA…
# Metadata.
meta <- aemet_daily_clim(c("9434", "3195"), extract_metadata = TRUE)
glimpse(meta$campos)
#> List of 27
#> $ :List of 4
#> ..$ id : chr "fecha"
#> ..$ descripcion: chr "fecha del dia (AAAA-MM-DD)"
#> ..$ tipo_datos : chr "string"
#> ..$ requerido : logi TRUE
#> $ :List of 4
#> ..$ id : chr "indicativo"
#> ..$ descripcion: chr "indicativo climatológico"
#> ..$ tipo_datos : chr "string"
#> ..$ requerido : logi TRUE
#> $ :List of 4
#> ..$ id : chr "nombre"
#> ..$ descripcion: chr "nombre (ubicación) de la estación"
#> ..$ tipo_datos : chr "string"
#> ..$ requerido : logi TRUE
#> $ :List of 4
#> ..$ id : chr "provincia"
#> ..$ descripcion: chr "provincia de la estación"
#> ..$ tipo_datos : chr "string"
#> ..$ requerido : logi TRUE
#> $ :List of 5
#> ..$ id : chr "altitud"
#> ..$ descripcion: chr "altitud de la estación en m sobre el nivel del mar"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "m"
#> ..$ requerido : logi TRUE
#> $ :List of 5
#> ..$ id : chr "tmed"
#> ..$ descripcion: chr "Temperatura media diaria"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "°C"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "prec"
#> ..$ descripcion: chr "Precipitación diaria de 07 a 07"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "mm (Ip = inferior a 0,1 mm) (Acum = Precipitación acumulada)"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "tmin"
#> ..$ descripcion: chr "Temperatura Mínima del día"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "°C"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horatmin"
#> ..$ descripcion: chr "Hora y minuto de la temperatura mínima"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "tmax"
#> ..$ descripcion: chr "Temperatura Máxima del día"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "°C"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horatmax"
#> ..$ descripcion: chr "Hora y minuto de la temperatura máxima"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "dir"
#> ..$ descripcion: chr "Dirección de la racha máxima"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "decenas de grado (99 = dirección variable)(88 = sin dato)"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "velmedia"
#> ..$ descripcion: chr "Velocidad media del viento"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "m/s"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "racha"
#> ..$ descripcion: chr "Racha máxima del viento"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "m/s"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horaracha"
#> ..$ descripcion: chr "Hora y minuto de la racha máxima"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "sol"
#> ..$ descripcion: chr "Insolación"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "horas"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "presmax"
#> ..$ descripcion: chr "Presión máxima al nivel de referencia de la estación"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "hPa"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horapresmax"
#> ..$ descripcion: chr "Hora de la presión máxima (redondeada a la hora entera más próxima)"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "presmin"
#> ..$ descripcion: chr "Presión mínima al nivel de referencia de la estación"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "hPa"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horapresmin"
#> ..$ descripcion: chr "Hora de la presión mínima (redondeada a la hora entera más próxima)"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "hrmedia"
#> ..$ descripcion: chr "Humedad relativa media diaria"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "%"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "hrmax"
#> ..$ descripcion: chr "Humedad relativa máxima diaria"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "%"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horahrmax"
#> ..$ descripcion: chr "Hora de la humedad relativa máxima diaria"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "hrmin"
#> ..$ descripcion: chr "Humedad relativa mínima diaria"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "%"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horahrmin"
#> ..$ descripcion: chr "Hora de la humedad relativa mínima diaria"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "pintmax"
#> ..$ descripcion: chr "Intensidad máxima de precipitación"
#> ..$ tipo_datos : chr "float"
#> ..$ unidad : chr "mm/h (-0,3 = precipitación inapreciable < 0,1 mm/h)"
#> ..$ requerido : logi FALSE
#> $ :List of 5
#> ..$ id : chr "horapintmax"
#> ..$ descripcion: chr "Hora de la intensidad máxima de precipitación"
#> ..$ tipo_datos : chr "string"
#> ..$ unidad : chr "UTC"
#> ..$ requerido : logi FALSE
