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> 2024-07-10, 2024-07-11, 2024-07-12, 2024-07-13, 2024-07-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> 28.6, 31.1, 23.6, 24.0, 26.9, 28.8, 26.4, 26.6
#> $ prec        <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ tmin        <dbl> 21.1, 22.9, 17.9, 16.9, 19.9, 21.0, 19.6, 19.1
#> $ horatmin    <time> 05:20:00, 23:59:00, 23:59:00, 05:20:00, 05:30:00, 05:30:00…
#> $ tmax        <dbl> 36.2, 39.3, 29.2, 31.0, 33.9, 36.7, 33.2, 34.1
#> $ horatmax    <time> 16:30:00, 16:20:00, 14:50:00, 15:20:00, 14:10:00, 14:10:00…
#> $ dir         <chr> "30", "30", "32", "32", "23", "26", "05", "04"
#> $ velmedia    <dbl> 3.1, 2.5, 9.2, 5.0, 2.2, 3.9, 2.2, 2.5
#> $ racha       <dbl> 7.5, 15.0, 15.3, 11.7, 8.3, 13.6, 9.7, 9.7
#> $ horaracha   <time> 00:30:00, 21:10:00, 06:50:00, 02:10:00, 13:10:00, 14:50:00…
#> $ sol         <dbl> 13.8, 13.0, 13.7, 9.3, NA, NA, NA, NA
#> $ presMax     <dbl> 987.8, 986.6, 986.8, 986.2, 942.2, 941.2, 939.3, 936.0
#> $ horaPresMax <chr> "08", "07", "22", "00", "08", "07", "08", "07"
#> $ presMin     <dbl> 984.6, 980.6, 984.1, 979.3, 939.6, 938.2, 935.0, 932.4
#> $ horaPresMin <chr> "17", "18", "17", "17", "00", "Varias", "18", "17"
#> $ hrMedia     <dbl> 40, 40, 45, 49, 42, 37, 27, 32
#> $ hrMax       <dbl> 70, 66, 66, 74, 66, 70, 58, 59
#> $ horaHrMax   <chr> "Varias", "05:10", "05:10", "23:59", "05:50", "06:20", "05…
#> $ hrMin       <dbl> 27, 24, 33, 39, 27, 19, 15, 14
#> $ horaHrMin   <chr> "Varias", "16:20", "14:50", "11:30", "14:40", "15:00", "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…