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-01'),
end_date = as.Date('2012-02-01'),
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 7529 features and 12 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -17.91528 ymin: 27.73583 xmax: 4.215556 ymax: 43.78611
#> Geodetic CRS: WGS 84
#> # A tibble: 7,529 × 13
#> timestamp service station_id station_name station_province altitude
#> <dttm> <chr> <chr> <chr> <chr> [m]
#> 1 2012-01-01 00:00:00 aemet 0016A "REUS AEROP… TARRAGONA 71
#> 2 2012-01-01 00:00:00 aemet 0076 "BARCELONA … BARCELONA 4
#> 3 2012-01-01 00:00:00 aemet 0149X "MANRESA" BARCELONA 291
#> 4 2012-01-01 00:00:00 aemet 0200E "BARCELONA,… BARCELONA 408
#> 5 2012-01-01 00:00:00 aemet 0367 "GIRONA AER… GIRONA 143
#> 6 2012-01-01 00:00:00 aemet 1002Y "BAZTAN, IR… NAVARRA 183
#> 7 2012-01-01 00:00:00 aemet 1014 "HONDARRIBI… GIPUZKOA 4
#> 8 2012-01-01 00:00:00 aemet 1014A "DONOSTIA /… GIPUZKOA 4
#> 9 2012-01-01 00:00:00 aemet 1024E "DONOSTIA /… GIPUZKOA 250
#> 10 2012-01-01 00:00:00 aemet 1037Y "ZUMARRAGA" GIPUZKOA 420
#> # ℹ 7,519 more rows
#> # ℹ 7 more variables: mean_temperature [°C], min_temperature [°C],
#> # max_temperature [°C], precipitation [L/m^2], mean_wind_speed [m/s],
#> # insolation [h], geometry <POINT [°]>
# }