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> 2025-12-03, 2025-12-04, 2025-12-05, 2025-12-06, 2025-12-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> 6.2, 8.8, 10.0, 13.6, NA, NA, NA, NA
#> $ prec <dbl> 1.0, 3.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
#> $ tmin <dbl> -0.4, 6.6, 6.5, 6.8, NA, NA, NA, NA
#> $ horatmin <time> 07:30:00, 18:40:00, 07:50:00, 06:40:00, NA, NA…
#> $ tmax <dbl> 12.8, 10.9, 13.5, 20.5, NA, NA, NA, NA
#> $ horatmax <time> 15:20:00, 10:50:00, 15:40:00, 13:40:00, NA, NA…
#> $ dir <chr> "32", "26", "28", "27", "32", "05", "03", "09"
#> $ velmedia <dbl> 4.7, 2.5, 2.2, 5.8, 1.9, 2.8, 2.5, 2.5
#> $ racha <dbl> 11.4, 12.5, 8.3, 14.7, 9.7, 18.3, 13.6, 8.9
#> $ horaracha <time> 12:40:00, 03:20:00, 09:40:00, 10:40:00, 14:40:00, 23:30:00…
#> $ sol <dbl> 8.6, 0.1, 8.0, 7.7, NA, NA, NA, NA
#> $ presMax <dbl> 987.4, 985.6, 987.1, 989.6, 942.4, 941.5, 942.9, 945.7
#> $ horaPresMax <chr> "21", "00", "21", "21", "20", "00", "24", "Varias"
#> $ presMin <dbl> 982.2, 981.7, 983.2, 986.5, 934.4, 936.9, 938.2, 942.4
#> $ horaPresMin <chr> "01", "16", "00", "01", "03", "14", "00", "02"
#> $ hrMedia <dbl> 70, 85, 80, 73, NA, NA, NA, NA
#> $ hrMax <dbl> 100, 92, 96, 93, NA, NA, NA, NA
#> $ horaHrMax <time> 07:50:00, 20:30:00, 05:30:00, 08:10:00, NA, NA…
#> $ hrMin <dbl> 48, 62, 64, 53, NA, NA, NA, NA
#> $ horaHrMin <chr> "15:30", "Varias", "15:40", "13: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…
