meteospain
2024-02-07
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 que poida ser
6#> utilizada libremente por eles, co único compromiso de mencionar expresamente a MeteoGalicia e á
7#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como fonte da mesma cada vez
8#> que as utilice para os usos distintos do particular e privado.
9#> https://www.meteogalicia.gal/web/informacion/notaIndex.action
10#> Simple feature collection with 3663 features and 14 fields
11#> Geometry type: POINT
12#> Dimension: XY
13#> Bounding box: xmin: -9.184586 ymin: 41.8982 xmax: -6.765224 ymax: 43.70426
14#> Geodetic CRS: WGS 84
15#> # A tibble: 3,663 × 15
16#> timestamp service station_id station_name station_province altitude temperature min_temperature max_temperature
17#> <dttm> <chr> <chr> <chr> <chr> [m] [°C] [°C] [°C]
18#> 1 2024-02-06 09:00:00 meteogalicia 10045 Mabegondo A Coruña 94 4.44 3.84 5.9
19#> 2 2024-02-06 09:00:00 meteogalicia 10046 Marco da Curra A Coruña 651 7.12 6.8 7.67
20#> 3 2024-02-06 09:00:00 meteogalicia 10047 Pedro Murias Lugo 51 10.0 9.62 10.5
21#> 4 2024-02-06 09:00:00 meteogalicia 10048 O Invernadeiro Ourense 1026 3.28 2.41 5.1
22#> 5 2024-02-06 09:00:00 meteogalicia 10049 Corrubedo A Coruña 30 9.01 8.8 9.17
23#> 6 2024-02-06 09:00:00 meteogalicia 10050 CIS Ferrol A Coruña 37 7.58 7.52 7.66
24#> 7 2024-02-06 09:00:00 meteogalicia 10052 Muralla A Coruña 661 7.56 7.34 7.95
25#> 8 2024-02-06 09:00:00 meteogalicia 10053 Campus Lugo Lugo 400 6.18 6.12 6.24
26#> 9 2024-02-06 09:00:00 meteogalicia 10055 Guitiriz-Mirador Lugo 684 7.02 6.18 7.61
27#> 10 2024-02-06 09:00:00 meteogalicia 10056 Marroxo Lugo 645 7.67 6.95 8.79
28#> # ℹ 3,653 more rows
29#> # ℹ 6 more variables: relative_humidity [%], precipitation [L/m^2], wind_direction [°], wind_speed [m/s], insolation [h],
30#> # 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 155 features and 5 fields
3#> Geometry type: POINT
4#> Dimension: XY
5#> Bounding box: xmin: -9.184586 ymin: 41.8982 xmax: -6.765224 ymax: 43.7383
6#> Geodetic CRS: WGS 84
7#> # A tibble: 155 × 6
8#> service station_id station_name station_province altitude geometry
9#> * <chr> <chr> <chr> <chr> [m] <POINT [°]>
10#> 1 meteogalicia 10157 Coruña-Torre de Hércules A Coruña 21 (-8.409202 43.38276)
11#> 2 meteogalicia 14000 Coruña-Dique A Coruña 5 (-8.374706 43.36506)
12#> 3 meteogalicia 10045 Mabegondo A Coruña 94 (-8.262225 43.24137)
13#> 4 meteogalicia 10144 Arzúa A Coruña 362 (-8.17469 42.93196)
14#> 5 meteogalicia 19005 Guísamo A Coruña 175 (-8.276487 43.30799)
15#> 6 meteogalicia 19012 Cespón A Coruña 59 (-8.854571 42.67466)
16#> 7 meteogalicia 10095 Sergude A Coruña 231 (-8.461246 42.82283)
17#> 8 meteogalicia 10800 Camariñas A Coruña 5 (-9.178318 43.12445)
18#> 9 meteogalicia 19001 Rus A Coruña 134 (-8.685357 43.15616)
19#> 10 meteogalicia 10147 Cariño A Coruña 20 (-7.88011 43.7383)
20#> # ℹ 145 more rows
Returned objects are spatial objects (using the
sf
R package), so results can be
plotted directly:
1library(sf)
2#> Linking to GEOS 3.10.2, GDAL 3.4.3, PROJ 8.2.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 que poida ser
6#> utilizada libremente por eles, co único compromiso de mencionar expresamente a MeteoGalicia e á
7#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como fonte da mesma cada vez
8#> que as utilice para os usos distintos do particular e privado.
9#> https://www.meteogalicia.gal/web/informacion/notaIndex.action
10#> Warning: plotting the first 9 out of 16 attributes; use max.plot = 16 to plot 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 autora de la misma.
3#> https://www.aemet.es/es/nota_legal
4#> Simple feature collection with 18471 features and 14 fields
5#> Geometry type: POINT
6#> Dimension: XY
7#> Bounding box: xmin: -18.115 ymin: 27.66667 xmax: 4.323889 ymax: 43.78621
8#> Geodetic CRS: WGS 84
9#> # A tibble: 18,471 × 15
10#> timestamp service station_id station_name station_province altitude temperature min_temperature max_temperature
11#> <dttm> <chr> <chr> <chr> <chr> [m] [°C] [°C] [°C]
12#> 1 2024-02-06 09:00:00 aemet 0009X ALFORJA <NA> 406 11 10.3 11
13#> 2 2024-02-06 09:00:00 aemet 0016A REUS/AEROPUERTO <NA> 71 9.3 7.2 9.5
14#> 3 2024-02-06 09:00:00 aemet 0034X VALLS <NA> 233 9.9 8.3 9.9
15#> 4 2024-02-06 09:00:00 aemet 0042Y TARRAGONA FAC. GEOG… <NA> 55 12.4 10.4 12.4
16#> 5 2024-02-06 09:00:00 aemet 0061X PONTONS <NA> 632 9.9 8.6 9.9
17#> 6 2024-02-06 09:00:00 aemet 0066X VILAFRANCA DEL PENED… <NA> 177 9.8 7.6 9.8
18#> 7 2024-02-06 09:00:00 aemet 0073X SITGES-VALLCARCA <NA> 58 10.8 9.1 10.8
19#> 8 2024-02-06 09:00:00 aemet 0076 BARCELONA/AEROPUERTO <NA> 4 9.8 8.8 9.9
20#> 9 2024-02-06 09:00:00 aemet 0092X BERGA INSTITUTO <NA> 682 6.6 5.6 6.6
21#> 10 2024-02-06 09:00:00 aemet 0106X BALSARENY <NA> 361 3.4 2 3.4
22#> # ℹ 18,461 more rows
23#> # ℹ 6 more variables: relative_humidity [%], precipitation [L/m^2], wind_direction [°], wind_speed [m/s], insolation [h],
24#> # geometry <POINT [°]>