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"))
glimpse(obs)
#> Rows: 8
#> Columns: 25
#> $ fecha <date> 2026-01-09, 2026-01-10, 2026-01-11, 2026-01-12, 2026-01-0…
#> $ 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> 10.9, 8.1, 8.2, 8.2, 8.5, 6.7, 5.4, 6.2
#> $ prec <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4
#> $ tmin <dbl> 6.0, 3.8, 2.0, 3.6, 4.9, 3.4, 0.7, 4.0
#> $ horatmin <time> 20:30:00, 07:10:00, 07:40:00, 08:10:00, 00:20:00, 23:59:00…
#> $ tmax <dbl> 15.8, 12.4, 14.4, 12.9, 12.1, 10.0, 10.0, 8.3
#> $ horatmax <time> 14:10:00, 13:10:00, 14:30:00, 15:30:00, 13:50:00, 15:40:00…
#> $ dir <chr> "29", "32", "27", "11", "05", "05", "34", "09"
#> $ velmedia <dbl> 9.4, 4.7, 2.8, 2.8, 4.4, 1.9, 1.1, 1.4
#> $ racha <dbl> 22.8, 15.6, 9.4, 6.7, 14.2, 8.6, 4.2, 5.8
#> $ horaracha <time> 14:00:00, 13:30:00, 02:40:00, 15:00:00, 15:30:00, 01:00:00…
#> $ sol <dbl> 6.5, 7.1, 8.8, 8.4, NA, NA, NA, NA
#> $ presMax <dbl> 990.8, 994.8, 995.0, 993.1, 946.6, 948.5, 948.4, 946.5
#> $ horaPresMax <chr> "24", "24", "10", "00", "00", "10", "10", "00"
#> $ presMin <dbl> 984.2, 990.8, 992.1, 987.7, 942.1, 944.6, 945.7, 939.1
#> $ horaPresMin <chr> "14", "00", "14", "24", "15", "01", "15", "24"
#> $ hrMedia <dbl> 56, 60, 67, 74, 61, 58, 76, 91
#> $ hrMax <dbl> 75, 73, 84, 89, 97, 74, 93, 99
#> $ horaHrMax <chr> "20:30", "07:10", "Varias", "Varias", "Varias", "23:59", "…
#> $ hrMin <dbl> 32, 43, 51, 58, 39, 39, 62, 79
#> $ horaHrMin <chr> "14:00", "13:30", "13:30", "Varias", "Varias", "16:10", "…
# 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…
