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-06-15, 2024-06-16, 2024-06-17, 2024-06-18, 2024-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> 21.9, 23.0, 26.4, 27.6, 23.0, 23.0, 23.2, 20.6
#> $ prec        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6
#> $ tmin        <dbl> 16.6, 14.4, 17.9, 20.3, 16.4, 15.5, 15.8, 15.0
#> $ horatmin    <time> 05:30:00, 03:50:00, 05:00:00, 04:30:00, 05:40:00, 04:40:00…
#> $ tmax        <dbl> 27.2, 31.5, 35.0, 34.8, 29.5, 30.5, 30.7, 26.2
#> $ horatmax    <chr> "Varias", "16:30", "15:20", "14:40", "13:30", "14:00", "14…
#> $ dir         <dbl> 30, 12, 12, 30, 27, 28, 25, 25
#> $ velmedia    <dbl> 5.3, 3.6, 4.2, 5.6, 2.5, 1.9, 2.5, 2.5
#> $ racha       <dbl> 11.7, 9.4, 11.9, 14.2, 8.6, 8.9, 9.7, 11.7
#> $ horaracha   <time> 10:00:00, 20:10:00, 19:10:00, 21:30:00, 14:20:00, 16:40:00…
#> $ sol         <dbl> 14.3, 14.3, 12.8, 9.5, NA, NA, NA, NA
#> $ presMax     <dbl> 985.2, 985.1, 982.8, 982.4, 937.4, 937.2, 936.6, 937.8
#> $ horaPresMax <chr> "23", "00", "Varias", "24", "23", "00", "08", "23"
#> $ presMin     <dbl> 981.6, 979.0, 977.3, 976.7, 934.9, 934.1, 933.3, 933.5
#> $ horaPresMin <chr> "17", "Varias", "17", "17", "17", "17", "17", "04"
#> $ hrMedia     <dbl> 41, 38, 41, 42, 32, 30, 36, 54
#> $ hrMax       <dbl> 63, 70, 81, 78, 67, 57, 66, 94
#> $ horaHrMax   <chr> "Varias", "04:10", "05:10", "04:00", "04:10", "01:00", "06…
#> $ hrMin       <dbl> 27, 24, 23, 25, 18, 18, 18, 29
#> $ horaHrMin   <chr> "16:20", "Varias", "15:00", "14:40", "13:20", "15: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…