Skip to contents

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 or FALSE. Should the function return an sf spatial object? If FALSE (the default value) it returns a tibble. Note that you need to have the sf package installed.

extract_metadata

Logical TRUE/FALSE. On TRUE the output is a tibble with the description of the fields. See also get_metadata_aemet().

progress

Logical, display a cli::cli_progress_bar() object. If verbose = TRUE won't be displayed.

Value

A tibble or a sf object.

Details

start and end arguments should be:

  • For aemet_daily_clim(): A Date object or a string with format YYYY-MM-DD ("2020-12-31") coercible with as.Date().

  • For aemet_daily_period() and aemet_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-04-01, 2026-04-02, 2026-04-03, 2026-04-04, 2026-04-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> 13.9, 12.8, 14.4, 17.4, 14.4, 12.8, 13.6, 16.6
#> $ prec        <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ tmin        <dbl> 9.7, 9.5, 8.9, 9.1, 8.7, 6.1, 5.8, 9.4
#> $ horatmin    <time> 02:00:00, 05:50:00, 03:00:00, 06:10:00, 06:10:00, 03:40:00…
#> $ tmax        <dbl> 18.1, 16.0, 19.8, 25.7, 20.2, 19.4, 21.4, 23.7
#> $ horatmax    <time> 13:50:00, 14:00:00, 15:50:00, 16:40:00, 14:40:00, 14:10:00…
#> $ dir         <chr> "32", "99", "31", "30", "99", "04", "34", "08"
#> $ velmedia    <dbl> 10.3, 8.3, 8.6, 1.4, 4.4, 3.9, 2.8, 1.4
#> $ racha       <dbl> 21.1, 18.9, 16.9, 10.3, 13.3, 11.9, 8.3, 5.8
#> $ horaracha   <chr> "15:10", "Varias", "08:00", "00:20", "Varias", "14:30", "1…
#> $ sol         <dbl> 12.2, 6.0, 9.6, 12.3, NA, NA, NA, NA
#> $ presMax     <dbl> 993.4, 991.9, 994.0, 994.7, 945.6, 943.6, 946.2, 947.2
#> $ horaPresMax <chr> "00", "23", "24", "10", "00", "24", "24", "09"
#> $ presMin     <dbl> 988.8, 987.4, 990.5, 989.9, 941.5, 939.9, 942.9, 943.4
#> $ horaPresMin <chr> "Varias", "05", "16", "17", "16", "Varias", "16", "Varias"
#> $ hrMedia     <dbl> 52, 53, 43, 38, 42, 39, 38, 46
#> $ hrMax       <dbl> 73, 71, 65, 64, 62, 69, 74, 76
#> $ horaHrMax   <chr> "02:50", "22:30", "Varias", "23:59", "06:50", "03:40", "04…
#> $ hrMin       <dbl> 40, 42, 28, 24, 29, 25, 20, 27
#> $ horaHrMin   <chr> "13:10", "15:10", "15:30", "Varias", "14:00", "16:40", "1…

# 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…