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 parameters 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-02-20, 2026-02-21, 2026-02-22, 2026-02-23, 2026-02-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> 10.4, 10.5, 10.8, 13.2, 8.1, 11.0, 12.0, 13.0
#> $ prec        <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ tmin        <dbl> 7.3, 4.2, 2.6, 4.0, 2.6, 4.3, 5.5, 6.0
#> $ horatmin    <chr> "01:10", "07:00", "06:40", "06:50", "08:00", "07:30", "07:…
#> $ tmax        <dbl> 13.6, 16.8, 18.9, 22.4, 13.6, 17.7, 18.5, 20.1
#> $ horatmax    <time> 15:20:00, 16:10:00, 15:00:00, 16:40:00, 16:50:00, 16:30:00…
#> $ dir         <chr> "32", "30", "24", "34", "05", "03", "06", "99"
#> $ velmedia    <dbl> 7.2, 1.9, 2.8, 2.2, 1.1, 1.1, 0.8, 1.7
#> $ racha       <dbl> 16.9, 12.2, 6.4, 5.0, 6.1, 5.3, 4.4, 3.9
#> $ horaracha   <chr> "11:30", "00:10", "14:10", "10:20", "23:59", "05:20", "03:…
#> $ sol         <dbl> 9.8, 10.5, 10.6, 10.6, NA, NA, NA, NA
#> $ presMax     <dbl> 999.8, 1002.2, 1000.4, 996.7, 951.4, 953.1, 952.0, 949.7
#> $ horaPresMax <chr> "24", "10", "00", "00", "11", "10", "10", "00"
#> $ presMin     <dbl> 995.4, 998.5, 996.3, 992.2, 948.3, 950.3, 948.9, 945.4
#> $ horaPresMin <chr> "00", "16", "17", "17", "00", "16", "16", "17"
#> $ hrMedia     <dbl> 61, 61, 65, 54, 58, 46, 48, 41
#> $ hrMax       <dbl> 70, 84, 91, 86, 89, 74, 73, 65
#> $ horaHrMax   <time> 00:00:00, 07:10:00, 05:40:00, 04:10:00, 08:00:00, 07:10:00…
#> $ hrMin       <dbl> 52, 40, 35, 22, 28, 24, 29, 26
#> $ horaHrMin   <time> 12:30:00, 15:10:00, 14:30:00, 15:50:00, 14:50:00, 14:10:00…

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