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: 291 × 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 B228       08301    PALMA, PUERTO          ILLES BA…       3     2.63    39.6
#>  3 B248       08303    SIERRA DE ALFABIA, BU… ILLES BA…    1030     2.71    39.7
#>  4 B278       08306    PALMA DE MALLORCA, AE… ILLES BA…       8     2.74    39.6
#>  5 B346X      08310    PORRERES               ILLES BA…     120     3.02    39.5
#>  6 B434X      08309    PORTOCOLOM             ILLES BA…      17     3.27    39.4
#>  7 B569X      08311    CAPDEPERA              ILLES BA…      57     3.48    39.7
#>  8 B691Y      08312    SA POBLA               ILLES BA…      40     3.02    39.7
#>  9 B893       08314    MENORCA, AEROPUERTO    ILLES BA…      91     4.22    39.9
#> 10 B954       08373    IBIZA, AEROPUERTO      ILLES BA…       6     1.38    38.9
#> # ℹ 281 more rows

# Cached during this R session
stations2 <- aemet_stations(verbose = TRUE)
#> Loading stations from temporal cached file saved at 2024-02-21 12:38:22 UTC

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