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 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-28, 2026-01-29, 2026-01-30, 2026-01-31, 2026-01-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> 6.0, 9.4, 9.2, 8.2, 5.0, 9.6, 7.8, 7.9
#> $ prec <dbl> 3.0, 0.8, 1.4, 0.2, 15.3, 6.8, 2.2, 0.0
#> $ tmin <dbl> 4.3, 5.9, 4.7, 4.0, 0.8, 6.1, 5.3, 4.9
#> $ horatmin <chr> "07:20", "Varias", "07:20", "07:40", "09:50", "03:00", "23…
#> $ tmax <dbl> 7.6, 12.9, 13.8, 12.3, 9.3, 13.2, 10.4, 10.9
#> $ horatmax <time> 00:00:00, 21:50:00, 12:50:00, 16:10:00, 14:30:00, 16:20:00…
#> $ dir <chr> "30", "28", "28", "33", "30", "06", "07", "28"
#> $ velmedia <dbl> 1.4, 2.5, 3.9, 3.9, 3.6, 2.2, 2.2, 3.6
#> $ racha <dbl> 11.4, 15.0, 17.8, 16.1, 15.6, 13.6, 15.6, 12.8
#> $ horaracha <time> 00:50:00, 21:30:00, 23:00:00, 01:10:00, 13:50:00, 16:10:00…
#> $ sol <dbl> 0.2, 1.4, 1.8, 6.3, NA, NA, NA, NA
#> $ presMax <dbl> 973.0, 974.0, 978.4, 985.3, 927.5, 932.4, 934.1, 939.6
#> $ horaPresMax <chr> "23", "24", "09", "21", "23", "23", "Varias", "21"
#> $ presMin <dbl> 965.0, 970.2, 968.9, 969.2, 913.0, 924.4, 925.1, 929.4
#> $ horaPresMin <chr> "10", "14", "23", "00", "10", "05", "19", "00"
#> $ hrMedia <dbl> 83, 93, 72, 70, 81, 92, 86, 58
#> $ hrMax <dbl> 93, 97, 89, 86, 99, 99, 96, 88
#> $ horaHrMax <chr> "19:30", "07:40", "07:40", "02:30", "Varias", "Varias", "V…
#> $ hrMin <dbl> 59, 63, 53, 56, 57, 64, 62, 43
#> $ horaHrMin <chr> "00:30", "Varias", "12:30", "15:00", "16:00", "16:20", "23…
# 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…
