Connect and retrieve data from AEMET, SMC and other Spanish meteorological stations services.
get_meteo_from(
service = c("aemet", "meteocat", "meteoclimatic", "meteogalicia", "ria"),
options
)
Character with the service name (in lower case).
List with the needed service options. See services_options
to have more info
about the different services and their options.
An sf (spatial) object with the stations meteorological data.
Depending on the service and the temporal resolution selected, the variables present can change, but all services have at least temperature values.
Some APIs have limits in terms of the data that can be retrieved with one call. For example, AEMET
only serves daily data for 31 days in one query. See vignette('api_limits', package = 'meteospain')
for a detailed explanations of those limits and the ways to retrieve longer periods.
In order to avoid unnecessary API calls, results of this function are cached in memory with
memoise
. This means that subsequent calls from get_meteo_from
with the same
arguments will be faster as they will not call the meteorological service API. This cache has a maximum
size of 1024 MB and persist 24 hours in the same R session after loading the package.
To forgot the cache, memoise::forget(get_meteo_from)
can be used.
# \donttest{
if (identical(Sys.getenv("NOT_CRAN"), "true")) {
library(meteospain)
library(keyring)
# AEMET (we need a key)
# key_set('aemet')
options_for_aemet <- aemet_options(
'daily',
start_date = as.Date('2012-01-16'),
end_date = as.Date('2012-01-31'),
api_key = key_get('aemet')
)
get_meteo_from('aemet', options_for_aemet)
}
#> ℹ © AEMET. Autorizado el uso de la información y su reproducción citando a
#> AEMET como autora de la misma.
#> https://www.aemet.es/es/nota_legal
#> Simple feature collection with 11994 features and 15 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -18.115 ymin: 27.66528 xmax: 4.323889 ymax: 43.78611
#> Geodetic CRS: WGS 84
#> # A tibble: 11,994 × 16
#> timestamp service station_id station_name station_province altitude
#> <dttm> <chr> <chr> <chr> <chr> [m]
#> 1 2012-01-16 00:00:00 aemet 0002I "VANDELLÒS … TARRAGONA 32
#> 2 2012-01-16 00:00:00 aemet 0009X "ALFORJA" TARRAGONA 406
#> 3 2012-01-16 00:00:00 aemet 0016A "REUS AEROP… TARRAGONA 71
#> 4 2012-01-16 00:00:00 aemet 0016B "REUS (CENT… TARRAGONA 118
#> 5 2012-01-16 00:00:00 aemet 0034X "VALLS" TARRAGONA 233
#> 6 2012-01-16 00:00:00 aemet 0042Y "TARRAGONA " TARRAGONA 55
#> 7 2012-01-16 00:00:00 aemet 0061X "PONTONS" BARCELONA 632
#> 8 2012-01-16 00:00:00 aemet 0066X "VILAFRANCA… BARCELONA 177
#> 9 2012-01-16 00:00:00 aemet 0073X "SITGES" BARCELONA 58
#> 10 2012-01-16 00:00:00 aemet 0076 "BARCELONA … BARCELONA 4
#> # ℹ 11,984 more rows
#> # ℹ 10 more variables: mean_temperature [°C], min_temperature [°C],
#> # max_temperature [°C], mean_relative_humidity [%],
#> # min_relative_humidity [%], max_relative_humidity [%],
#> # precipitation [L/m^2], mean_wind_speed [m/s], insolation [h],
#> # geometry <POINT [°]>
# }