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"))
glimpse(obs)
#> Rows: 8
#> Columns: 25
#> $ fecha <date> 2025-02-03, 2025-02-04, 2025-02-05, 2025-02-06, 2025-02-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> 8.4, 6.4, 10.0, 7.2, 7.2, 7.6, 8.1, 7.2
#> $ prec <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ tmin <dbl> 3.6, -0.1, 5.4, 0.7, 3.2, 2.4, 2.2, 1.9
#> $ horatmin <time> 23:59:00, 08:10:00, 07:30:00, 07:30:00, 07:50:00, 07:50:00…
#> $ tmax <dbl> 13.2, 12.8, 14.5, 13.7, 11.3, 12.7, 14.0, 12.5
#> $ horatmax <time> 15:40:00, 15:30:00, 15:30:00, 15:50:00, 14:50:00, 13:50:00…
#> $ dir <chr> "31", "30", "30", "32", "04", "05", "05", "04"
#> $ velmedia <dbl> 4.7, 2.8, 5.0, 0.8, 1.9, 1.4, 0.8, 1.4
#> $ racha <dbl> 9.2, 8.6, 9.4, 5.3, 8.6, 5.8, 4.4, 4.4
#> $ horaracha <time> 11:20:00, 23:40:00, 11:50:00, 12:20:00, 00:10:00, 00:30:00…
#> $ sol <dbl> 9.6, 9.2, 9.8, 9.8, NA, NA, NA, NA
#> $ presMax <dbl> 996.6, 1001.0, 1003.9, 1002.0, 946.8, 952.3, 954.8, 952.0
#> $ horaPresMax <chr> "24", "24", "10", "00", "24", "24", "10", "00"
#> $ presMin <dbl> 992.6, 996.6, 1000.6, 993.5, 942.5, 946.7, 951.3, 944.8
#> $ horaPresMin <chr> "00", "00", "16", "24", "00", "Varias", "16", "24"
#> $ hrMedia <dbl> 72, 77, 61, 70, 62, 59, 55, 54
#> $ hrMax <dbl> 89, 97, 79, 95, 84, 82, 85, 76
#> $ horaHrMax <time> 03:20:00, 07:20:00, 23:59:00, 07:00:00, 07:30:00, 07:30:00…
#> $ hrMin <dbl> 52, 58, 46, 48, 40, 42, 30, 37
#> $ horaHrMin <chr> "14:40", "14:50", "Varias", "Varias", "15:50", "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…