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: 10
#> Columns: 25
#> $ fecha       <date> 2024-06-16, 2024-06-17, 2024-06-18, 2024-06-19, 2024-06-2…
#> $ indicativo  <chr> "9434", "9434", "9434", "9434", "9434", "3195", "3195", "3…
#> $ nombre      <chr> "ZARAGOZA, AEROPUERTO", "ZARAGOZA, AEROPUERTO", "ZARAGOZA,…
#> $ provincia   <chr> "ZARAGOZA", "ZARAGOZA", "ZARAGOZA", "ZARAGOZA", "ZARAGOZA"…
#> $ altitud     <dbl> 249, 249, 249, 249, 249, 667, 667, 667, 667, 667
#> $ tmed        <dbl> 23.0, 26.4, 27.6, 24.9, 19.0, 23.0, 23.2, 20.6, 19.2, 17.4
#> $ prec        <dbl> 0.0, 0.0, 0.0, 4.0, 1.8, 0.0, 0.0, 0.6, 1.7, 7.2
#> $ tmin        <dbl> 14.4, 17.9, 20.3, 19.4, 15.4, 15.5, 15.8, 15.0, 14.0, 13.1
#> $ horatmin    <time> 03:50:00, 05:00:00, 04:30:00, 23:59:00, 12:10:00, 04:40:00…
#> $ tmax        <dbl> 31.5, 35.0, 34.8, 30.4, 22.6, 30.5, 30.7, 26.2, 24.5, 21.7
#> $ horatmax    <time> 16:30:00, 15:20:00, 14:40:00, 15:10:00, 15:10:00, 14:00:00…
#> $ dir         <dbl> 12, 12, 30, 32, 30, 28, 25, 25, 23, 30
#> $ velmedia    <dbl> 3.6, 4.2, 5.6, 4.2, 6.7, 1.9, 2.5, 2.5, 1.1, 1.9
#> $ racha       <dbl> 9.4, 11.9, 14.2, 14.7, 15.8, 8.9, 9.7, 11.7, 12.8, 8.6
#> $ horaracha   <time> 20:10:00, 19:10:00, 21:30:00, 21:00:00, 11:40:00, 16:40:00…
#> $ sol         <dbl> 14.3, 12.8, 9.5, 12.5, 6.3, NA, NA, NA, NA, NA
#> $ presMax     <dbl> 985.1, 982.8, 982.4, 985.0, 989.2, 937.2, 936.6, 937.8, 93…
#> $ horaPresMax <chr> "00", "Varias", "24", "23", "24", "00", "08", "23", "21",…
#> $ presMin     <dbl> 979.0, 977.3, 976.7, 980.4, 983.4, 934.1, 933.3, 933.5, 93…
#> $ horaPresMin <chr> "Varias", "17", "17", "17", "04", "17", "17", "04", "17",…
#> $ hrMedia     <dbl> 38, 41, 42, 35, 64, 30, 36, 54, 51, 80
#> $ hrMax       <dbl> 70, 81, 78, 61, 82, 57, 66, 94, 94, 96
#> $ horaHrMax   <chr> "04:10", "05:10", "04:00", "21:40", "05:40", "01:00", "06:…
#> $ hrMin       <dbl> 24, 23, 25, 21, 46, 18, 18, 29, 34, 47
#> $ horaHrMin   <chr> "Varias", "15:00", "14:40", "15:10", "Varias", "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…