Skip to contents

Get AEMET stations.

Usage

aemet_stations(verbose = FALSE, return_sf = FALSE)

Arguments

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.

Value

A tibble or a sf object

Details

The first result of the API call on each session is (temporarily) cached in the assigned tempdir() for avoiding unneeded API calls.

Note

Code modified from project https://github.com/SevillaR/aemet

API Key

You need to set your API Key globally using aemet_api_key().

Examples

library(tibble)
stations <- aemet_stations()
stations
#> # A tibble: 870 × 7
#>    indicativo indsinop nombre                 provincia altitud longitud latitud
#>    <chr>      <chr>    <chr>                  <chr>       <dbl>    <dbl>   <dbl>
#>  1 B013X      "08304"  ESCORCA, LLUC          ILLES BA…     490     2.89    39.8
#>  2 B051A      "08316"  SÓLLER, PUERTO         ILLES BA…       5     2.69    39.8
#>  3 B087X      ""       BANYALBUFAR            ILLES BA…      60     2.51    39.7
#>  4 B103B      "99103"  ANDRATX - SANT ELM     ILLES BA…      52     2.37    39.6
#>  5 B158X      ""       CALVIÀ, ES CAPDELLÀ    ILLES BA…      50     2.47    39.6
#>  6 B228       "08301"  PALMA, PUERTO          ILLES BA…       3     2.63    39.6
#>  7 B236C      ""       PALMA, UNIVERSIDAD     ILLES BA…      95     2.64    39.6
#>  8 B248       "08303"  SIERRA DE ALFABIA, BU… ILLES BA…    1030     2.71    39.7
#>  9 B275E      "08302"  SON BONET, AEROPUERTO  BALEARES       49     2.71    39.6
#> 10 B278       "08306"  PALMA DE MALLORCA, AE… ILLES BA…       8     2.74    39.6
#> # ℹ 860 more rows

# Cached during this R session
stations2 <- aemet_stations(verbose = TRUE)
#> Loading stations from temporal cached file saved at 2024-03-27 12:45:14 UTC

identical(stations, stations2)
#> [1] TRUE