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
)

aemet_daily_period(
  station,
  start = as.integer(format(Sys.Date(), "%Y")),
  end = start,
  verbose = FALSE,
  return_sf = FALSE,
  extract_metadata = FALSE
)

aemet_daily_period_all(
  start = as.integer(format(Sys.Date(), "%Y")),
  end = start,
  verbose = FALSE,
  return_sf = FALSE,
  extract_metadata = FALSE
)

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().

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: 6
#> Columns: 20
#> $ fecha       <date> 2024-02-14, 2024-02-15, 2024-02-16, 2024-02-14, 2024-02-1…
#> $ indicativo  <chr> "9434", "9434", "9434", "3195", "3195", "3195"
#> $ nombre      <chr> "ZARAGOZA, AEROPUERTO", "ZARAGOZA, AEROPUERTO", "ZARAGOZA,…
#> $ provincia   <chr> "ZARAGOZA", "ZARAGOZA", "ZARAGOZA", "MADRID", "MADRID", "M…
#> $ altitud     <dbl> 249, 249, 249, 667, 667, 667
#> $ tmed        <dbl> 11.6, 13.4, 12.8, 14.2, 12.2, 11.7
#> $ prec        <dbl> 0.0, 2.0, 0.0, 0.0, 4.3, 0.0
#> $ tmin        <dbl> 5.2, 8.7, 9.4, 11.1, 10.4, 8.3
#> $ horatmin    <time> 06:40:00, 04:30:00, 22:50:00, 00:00:00, 23:59:00, 23:50:00
#> $ tmax        <dbl> 18.1, 18.0, 16.1, 17.3, 14.0, 15.1
#> $ horatmax    <chr> "15:40", "14:30", "15:40", "15:10", "Varias", "13:30"
#> $ dir         <chr> "99", "12", "31", "03", "27", "28"
#> $ velmedia    <dbl> 2.5, 3.1, 6.9, 1.9, 2.2, 1.1
#> $ racha       <dbl> 5.8, 10.6, 14.4, 5.3, 8.3, 8.1
#> $ horaracha   <chr> "Varias", "12:40", "09:20", "10:40", "22:00", "03:00"
#> $ sol         <dbl> 6.2, 2.8, 2.2, NA, NA, NA
#> $ presMax     <dbl> 996.0, 990.9, 997.2, 947.2, 942.2, 949.4
#> $ horaPresMax <chr> "09", "00", "24", "09", "00", "24"
#> $ presMin     <dbl> 990.9, 984.9, 986.1, 942.1, 937.3, 939.8
#> $ horaPresMin <chr> "24", "16", "00", "24", "16", "00"

# Metadata
meta <- aemet_daily_clim(c("9434", "3195"), extract_metadata = TRUE)

glimpse(meta$campos)
#> Rows: 20
#> 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…