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
TRUE
orFALSE
. Should the function return ansf
spatial object? IfFALSE
(the default value) it returns atibble
. Note that you need to have the sf package installed.- extract_metadata
Logical
TRUE/FALSE
. OnTRUE
the output is atibble
with the description of the fields. See alsoget_metadata_aemet()
.- progress
Logical, display a
cli::cli_progress_bar()
object. Ifverbose = TRUE
won't be displayed.
Details
start
and end
parameters should be:
For
aemet_daily_clim()
: ADate
object 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()
.
See also
Other aemet_api_data:
aemet_alert_zones()
,
aemet_alerts()
,
aemet_beaches()
,
aemet_extremes_clim()
,
aemet_forecast_beaches()
,
aemet_forecast_daily()
,
aemet_forecast_fires()
,
aemet_last_obs()
,
aemet_monthly
,
aemet_normal
,
aemet_stations()
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 3s for retry backoff ■■■■■■■■■■■■
#> Waiting 3s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 3s for retry backoff ■■■■■■■■■■■■■■■
#> Waiting 3s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 16s for retry backoff ■■■
#> Waiting 16s for retry backoff ■■■■■■
#> Waiting 16s for retry backoff ■■■■■■■■■■■■
#> Waiting 16s for retry backoff ■■■■■■■■■■■■■■■■■
#> Waiting 16s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 16s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> Waiting 16s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
glimpse(obs)
#> Rows: 8
#> Columns: 25
#> $ fecha <date> 2025-06-10, 2025-06-11, 2025-06-12, 2025-06-13, 2025-06-1…
#> $ 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> 30.1, 27.8, 26.6, 28.1, 27.0, 24.0, 22.4, 24.5
#> $ prec <dbl> 0.0, 0.0, 0.0, 3.6, 0.1, 17.8, NA, 0.0
#> $ tmin <dbl> 20.9, 21.6, 17.9, 20.8, 20.4, 17.7, 15.4, 17.6
#> $ horatmin <time> 04:50:00, 23:50:00, 04:50:00, 04:50:00, 05:50:00, 23:59:00…
#> $ tmax <dbl> 39.3, 34.1, 35.3, 35.4, 33.7, 30.3, 29.4, 31.4
#> $ horatmax <time> 15:50:00, 17:20:00, 17:00:00, 14:00:00, 13:20:00, 14:20:00…
#> $ dir <chr> "28", "31", "14", "99", "11", "04", "06", "04"
#> $ velmedia <dbl> 3.1, 3.6, 1.4, 5.3, 1.4, 1.7, 1.7, 1.7
#> $ racha <dbl> 13.3, 13.3, 6.9, 11.7, 8.3, 12.5, 6.9, 6.9
#> $ horaracha <chr> "19:00", "21:40", "21:00", "Varias", "13:20", "00:50", "14…
#> $ sol <dbl> 11.3, 6.1, 13.8, 9.4, NA, NA, NA, NA
#> $ presMax <dbl> 989.7, 987.4, 984.9, 987.9, 943.9, 942.6, 938.9, 940.9
#> $ horaPresMax <chr> "00", "00", "24", "20", "00", "01", "Varias", "23"
#> $ presMin <dbl> 985.1, 980.0, 981.7, 982.8, 939.4, 934.4, 936.6, 938.3
#> $ horaPresMin <chr> "16", "18", "17", "16", "24", "19", "03", "Varias"
#> $ hrMedia <dbl> 39, 36, 39, 56, 39, 66, 53, 34
#> $ hrMax <dbl> 79, 68, 81, 79, 74, 99, 99, 63
#> $ horaHrMax <time> 05:00:00, 05:20:00, 05:20:00, 20:00:00, 06:10:00, 19:30:00…
#> $ hrMin <dbl> 18, 23, 22, 33, 25, 35, 27, 24
#> $ horaHrMin <time> 15:50:00, 16:00:00, 17:30:00, 14:00:00, 15:40:00, 13:40:0…
# 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…