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 a tibble. Note that you need to have the sf package installed.- extract_metadata
Logical
TRUE/FALSE. OnTRUEthe output is a tibble with 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 arguments should be:
For
aemet_daily_clim(): ADateobject or a string with formatYYYY-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-05-06, 2026-05-07, 2026-05-08, 2026-05-09, 2026-05-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> 14.4, 15.0, 16.1, 16.6, 14.2, 14.6, 13.6, 13.2
#> $ prec <dbl> 0.0, 3.8, 0.0, 0.4, 0.0, 10.8, 3.6, 12.5
#> $ tmin <dbl> 8.1, 9.1, 10.1, 13.1, 8.6, 10.8, 10.0, 10.7
#> $ horatmin <chr> "05:00", "05:00", "04:20", "03:40", "06:10", "23:59", "04:…
#> $ tmax <dbl> 20.7, 20.9, 22.1, 20.1, 19.7, 18.3, 17.2, 15.7
#> $ horatmax <time> 14:50:00, 12:20:00, 15:20:00, 17:00:00, 15:00:00, 11:40:00…
#> $ dir <chr> "30", "24", "12", "12", "99", "34", "15", "09"
#> $ velmedia <dbl> 3.1, 2.5, 4.2, 5.3, 1.9, 3.3, 1.4, 2.8
#> $ racha <dbl> 10.6, 11.7, 11.7, 11.4, 5.6, 10.0, 7.5, 15.3
#> $ horaracha <chr> "11:30", "14:40", "16:10", "13:40", "Varias", "13:20", "15…
#> $ sol <dbl> 13.8, 5.9, 5.2, 2.2, NA, NA, NA, NA
#> $ presMax <dbl> 984.1, 983.7, 983.4, 983.0, 935.6, 935.2, 934.7, 935.3
#> $ horaPresMax <chr> "07", "07", "08", "00", "Varias", "22", "00", "23"
#> $ presMin <dbl> 981.0, 980.4, 979.8, 979.4, 932.0, 932.1, 932.0, 931.3
#> $ horaPresMin <chr> "Varias", "16", "16", "17", "18", "16", "18", "Varias"
#> $ hrMedia <dbl> 51, 70, 70, 76, 43, 76, 75, 91
#> $ hrMax <dbl> 89, 94, 97, 91, 78, 95, 96, 97
#> $ horaHrMax <chr> "05:00", "23:59", "03:30", "Varias", "06:00", "15:30", "10…
#> $ hrMin <dbl> 34, 45, 43, 55, 25, 45, 54, 73
#> $ horaHrMin <chr> "14:20", "12:30", "15:20", "16:50", "Varias", "00:00", "17…
# 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…
