Get climatology values for a station or for all the available stations.
Note that aemet_daily_period() and aemet_daily_period_all() are shortcuts
of 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
Character string with station identifier code(s) (see
aemet_stations()) or "all" for all the stations.- start, end
Character string with start and end date. See Details.
- verbose
Logical
TRUE/FALSE. Provides information about the flow of information between the client and server.- return_sf
Logical
TRUEorFALSE. Should the function return ansfspatial object? IfFALSE(the default value) it returns atibble. Note that you need to have the sf package installed.- extract_metadata
Logical
TRUE/FALSE. OnTRUEthe output is atibblewith the description of the fields. See alsoget_metadata_aemet().- progress
Logical, display a
cli::cli_progress_bar()object. Ifverbose = TRUEwon't be displayed.
Details
start and end parameters should be:
For
aemet_daily_clim(): ADateobject or a string with format:YYYY-MM-DD("2020-12-31") coercible withas.Date().For
aemet_daily_period()andaemet_daily_period_all(): A string representing the year(s) to be extracted:"2020","2018".
API Key
You need to set your API Key globally using aemet_api_key().
Examples
library(tibble)
obs <- aemet_daily_clim(c("9434", "3195"))
#> HTTP 429: Límite de peticiones o caudal por minuto excedido para este usuario. Espere al siguiente minuto. Retrying...
#> Waiting 4s for retry backoff ■■■■■■■■■■
#> Waiting 4s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 7s for retry backoff ■■■■■
#> Waiting 7s for retry backoff ■■■■■■■■■■■■■
#> Waiting 7s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 7s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 8s for retry backoff ■■■■■■■
#> Waiting 8s for retry backoff ■■■■■■■■■■■■■■■■■■■■
#> Waiting 8s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
glimpse(obs)
#> Rows: 8
#> Columns: 25
#> $ fecha <date> 2025-11-26, 2025-11-27, 2025-11-28, 2025-11-29, 2025-11-2…
#> $ 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> 8.0, 10.8, 10.3, 7.4, NA, NA, NA, NA
#> $ prec <dbl> 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0, 3.3
#> $ tmin <dbl> 5.0, 6.0, 5.5, 1.9, NA, NA, NA, NA
#> $ horatmin <time> 07:20:00, 03:40:00, 23:59:00, 06:50:00, NA, NA…
#> $ tmax <dbl> 11.1, 15.5, 15.1, 12.9, NA, NA, NA, NA
#> $ horatmax <time> 14:20:00, 14:10:00, 14:50:00, 14:30:00, NA, NA…
#> $ dir <chr> "31", "32", "24", "24", "11", "06", "03", "03"
#> $ velmedia <dbl> 8.9, 7.8, 4.2, 1.7, 1.1, 0.3, 0.8, 1.1
#> $ racha <dbl> 15.8, 16.9, 10.0, 5.0, 7.2, 3.6, 5.0, 6.7
#> $ horaracha <time> 12:10:00, 10:30:00, 03:10:00, 17:50:00, 15:40:00, 13:10:00…
#> $ sol <dbl> 9.0, 9.1, 8.6, 7.5, NA, NA, NA, NA
#> $ presMax <dbl> 993.1, 992.4, 991.8, 989.5, 946.4, 945.8, 944.8, 941.9
#> $ horaPresMax <chr> "10", "00", "00", "00", "10", "02", "10", "00"
#> $ presMin <dbl> 989.6, 990.0, 989.0, 982.7, 943.1, 943.1, 941.5, 936.2
#> $ horaPresMin <chr> "Varias", "14", "15", "22", "00", "15", "16", "24"
#> $ hrMedia <dbl> 68, 65, 71, 78, NA, NA, NA, NA
#> $ hrMax <dbl> 89, 81, 88, 95, NA, NA, NA, NA
#> $ horaHrMax <chr> "02:30", "23:10", "Varias", "07:30", NA, NA, NA, NA
#> $ hrMin <dbl> 49, 50, 53, 59, NA, NA, NA, NA
#> $ horaHrMin <chr> "14:00", "13:30", "Varias", "14:30", NA, NA, NA, NA
# Metadata
meta <- aemet_daily_clim(c("9434", "3195"), extract_metadata = TRUE)
glimpse(meta$campos)
#> Rows: 25
#> Columns: 5
#> $ id <chr> "fecha", "indicativo", "nombre", "provincia", "altitud", "…
#> $ descripcion <chr> "fecha del dia (AAAA-MM-DD)", "indicativo climatológico", …
#> $ tipo_datos <chr> "string", "string", "string", "string", "float", "float", …
#> $ requerido <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, …
#> $ unidad <chr> NA, NA, NA, NA, "m", "°C", "mm (Ip = inferior a 0,1 mm) (A…
