meteospain
2024-11-25
Víctor Granda-García
Ecosystem Modelling Facility - CREAFMiquel de Cáceres
Ecosystem Modelling Facility - CREAFAitor Ameztegui
University of LleidaEcosystem Modelling Facility
Ecosystem Modelling Facility - CREAFmeteospain
meteospain
aims to offer access to different Spanish meteorological
stations data in an uniform way.
Installation
meteospain
is in CRAN, and can be installed as any other package:
1install.packages('meteospain')
Also, meteospain
is in active development. You can install the
development version from GitHub with:
1# install.packages("remotes")
2remotes::install_github("emf-creaf/meteospain")
Services
The following meteorological stations services are available:
- AEMET, the Spanish State Meteorological Agency.
- MeteoCat, the Catalan Meteorology Service.
- MeteoGalicia, the Galician Meteorological Service.
- RIA, the Andalucian Agroclimatic Information Network.
- Meteoclimatic, the Spanish non-professional meteorological stations network.
Examples
Access to the services is done with the get_meteo_from
function,
providing the name of the service and the options. Each service has a
dedicated *service*_options()
function to guide through the specifics
of each service:
1library(meteospain)
2
3mg_options <- meteogalicia_options(resolution = 'current_day')
4get_meteo_from('meteogalicia', mg_options)
5#> ℹ A información divulgada a través deste servidor ofrécese gratuitamente aos cidadáns para
6#> que poida ser
7#> utilizada libremente por eles, co único compromiso de mencionar expresamente a MeteoGalicia
8#> e á
9#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como fonte da mesma
10#> cada vez
11#> que as utilice para os usos distintos do particular e privado.
12#> https://www.meteogalicia.gal/web/informacion/notaIndex.action
13#> Simple feature collection with 3638 features and 14 fields
14#> Geometry type: POINT
15#> Dimension: XY
16#> Bounding box: xmin: -9.184586 ymin: 41.90361 xmax: -6.765224 ymax: 43.70426
17#> Geodetic CRS: WGS 84
18#> # A tibble: 3,638 × 15
19#> timestamp service station_id station_name station_province altitude
20#> <dttm> <chr> <chr> <chr> <chr> [m]
21#> 1 2024-11-24 08:00:00 meteog… 10045 Mabegondo A Coruña 94
22#> 2 2024-11-24 08:00:00 meteog… 10046 Marco da Cu… A Coruña 651
23#> 3 2024-11-24 08:00:00 meteog… 10047 Pedro Murias Lugo 51
24#> 4 2024-11-24 08:00:00 meteog… 10048 O Invernade… Ourense 1026
25#> 5 2024-11-24 08:00:00 meteog… 10049 Corrubedo A Coruña 30
26#> 6 2024-11-24 08:00:00 meteog… 10050 CIS Ferrol A Coruña 37
27#> 7 2024-11-24 08:00:00 meteog… 10052 Muralla A Coruña 661
28#> 8 2024-11-24 08:00:00 meteog… 10053 Campus Lugo Lugo 400
29#> 9 2024-11-24 08:00:00 meteog… 10055 Guitiriz-Mi… Lugo 684
30#> 10 2024-11-24 08:00:00 meteog… 10056 Marroxo Lugo 645
31#> # ℹ 3,628 more rows
32#> # ℹ 9 more variables: temperature [°C], min_temperature [°C],
33#> # max_temperature [°C], relative_humidity [%], precipitation [L/m^2],
34#> # wind_direction [°], wind_speed [m/s], insolation [h], geometry <POINT [°]>
Stations info can be accessed with get_stations_info_from
function:
1get_stations_info_from('meteogalicia', mg_options)
2#> Simple feature collection with 153 features and 5 fields
3#> Geometry type: POINT
4#> Dimension: XY
5#> Bounding box: xmin: -9.184586 ymin: 41.90361 xmax: -6.765224 ymax: 43.7383
6#> Geodetic CRS: WGS 84
7#> # A tibble: 153 × 6
8#> service station_id station_name station_province altitude
9#> * <chr> <chr> <chr> <chr> [m]
10#> 1 meteogalicia 10157 Coruña-Torre de Hércules A Coruña 21
11#> 2 meteogalicia 14000 Coruña-Dique A Coruña 5
12#> 3 meteogalicia 10045 Mabegondo A Coruña 94
13#> 4 meteogalicia 14003 Punta Langosteira A Coruña 5
14#> 5 meteogalicia 10144 Arzúa A Coruña 362
15#> 6 meteogalicia 19005 Guísamo A Coruña 175
16#> 7 meteogalicia 10095 Sergude A Coruña 231
17#> 8 meteogalicia 10800 Camariñas A Coruña 5
18#> 9 meteogalicia 19001 Rus A Coruña 134
19#> 10 meteogalicia 10147 Cariño A Coruña 20
20#> # ℹ 143 more rows
21#> # ℹ 1 more variable: geometry <POINT [°]>
Returned objects are spatial objects (using the
sf
R package), so results can be
plotted directly:
1library(sf)
2#> Linking to GEOS 3.11.1, GDAL 3.6.4, PROJ 9.1.1; sf_use_s2() is TRUE
3mg_options <- meteogalicia_options(resolution = 'daily', start_date = as.Date('2021-04-25'))
4plot(get_meteo_from('meteogalicia', mg_options))
5#> ℹ A información divulgada a través deste servidor ofrécese gratuitamente aos cidadáns para
6#> que poida ser
7#> utilizada libremente por eles, co único compromiso de mencionar expresamente a MeteoGalicia
8#> e á
9#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como fonte da mesma
10#> cada vez
11#> que as utilice para os usos distintos do particular e privado.
12#> https://www.meteogalicia.gal/web/informacion/notaIndex.action
13#> Warning: plotting the first 9 out of 16 attributes; use max.plot = 16 to plot
14#> all
1
2plot(get_stations_info_from('meteogalicia', mg_options))
API keys
Some services, like AEMET or Meteocat, require an API key to access
the data. meteospain
doesn’t provide any key for those services,
see ?services_options
for information about this.
Once a key has been obtained, we can get the meteo:
1get_meteo_from('aemet', aemet_options(api_key = keyring::key_get("aemet")))
2#> ℹ © AEMET. Autorizado el uso de la información y su reproducción citando a AEMET como
3#> autora de la misma.
4#> https://www.aemet.es/es/nota_legal
5#> Simple feature collection with 10154 features and 14 fields
6#> Geometry type: POINT
7#> Dimension: XY
8#> Bounding box: xmin: -18.115 ymin: 27.72528 xmax: 4.323889 ymax: 43.78621
9#> Geodetic CRS: WGS 84
10#> # A tibble: 10,154 × 15
11#> timestamp service station_id station_name station_province altitude
12#> <dttm> <chr> <chr> <chr> <chr> [m]
13#> 1 2024-11-24 19:00:00 aemet 0009X ALFORJA TARRAGONA 406
14#> 2 2024-11-24 19:00:00 aemet 0016A REUS/AEROPU… <NA> 71
15#> 3 2024-11-24 19:00:00 aemet 0034X VALLS TARRAGONA 233
16#> 4 2024-11-24 19:00:00 aemet 0042Y TARRAGONA … <NA> 55
17#> 5 2024-11-24 19:00:00 aemet 0061X PONTONS BARCELONA 632
18#> 6 2024-11-24 19:00:00 aemet 0066X VILAFRANCA … BARCELONA 177
19#> 7 2024-11-24 19:00:00 aemet 0073X SITGES-VALL… <NA> 58
20#> 8 2024-11-24 19:00:00 aemet 0076 BARCELONA/A… <NA> 4
21#> 9 2024-11-24 19:00:00 aemet 0092X BERGA INST… <NA> 682
22#> 10 2024-11-24 19:00:00 aemet 0106X BALSARENY BARCELONA 361
23#> # ℹ 10,144 more rows
24#> # ℹ 9 more variables: temperature [°C], min_temperature [°C],
25#> # max_temperature [°C], relative_humidity [%], precipitation [L/m^2],
26#> # wind_direction [°], wind_speed [m/s], insolation [h], geometry <POINT [°]>