meteospain

2026-02-04

meteospain

meteospain

R-CMD-check CRAN-status CRAN-RStudio-mirror-downloads

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", ref = "devel")

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
 6#>   cidadáns para que poida ser
 7#> utilizada libremente por eles, co único compromiso de mencionar expresamente a
 8#> MeteoGalicia e á
 9#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como
10#> fonte da mesma cada vez
11#> que as utilice para os usos distintos do particular e privado.
12#> https://www.meteogalicia.gal/aviso-legal
13#> Simple feature collection with 3601 features and 17 fields
14#> Geometry type: POINT
15#> Dimension:     XY
16#> Bounding box:  xmin: -9.184586 ymin: 41.8982 xmax: -6.765224 ymax: 43.70426
17#> Geodetic CRS:  WGS 84
18#> # A tibble: 3,601 × 18
19#>    timestamp           service station_id station_name station_province altitude
20#>    <dttm>              <chr>   <chr>      <chr>        <chr>                 [m]
21#>  1 2026-02-03 04:00:00 meteog… 10045      Mabegondo    A Coruña               94
22#>  2 2026-02-03 04:00:00 meteog… 10046      Marco da Cu… A Coruña              651
23#>  3 2026-02-03 04:00:00 meteog… 10047      Pedro Murias Lugo                   51
24#>  4 2026-02-03 04:00:00 meteog… 10048      O Invernade… Ourense              1026
25#>  5 2026-02-03 04:00:00 meteog… 10049      Corrubedo    A Coruña               30
26#>  6 2026-02-03 04:00:00 meteog… 10050      CIS Ferrol   A Coruña               37
27#>  7 2026-02-03 04:00:00 meteog… 10052      Muralla      A Coruña              661
28#>  8 2026-02-03 04:00:00 meteog… 10053      Campus Lugo  Lugo                  400
29#>  9 2026-02-03 04:00:00 meteog… 10055      Guitiriz-Mi… Lugo                  684
30#> 10 2026-02-03 04:00:00 meteog… 10056      Marroxo      Lugo                  645
31#> # ℹ 3,591 more rows
32#> # ℹ 12 more variables: temperature [°C], min_temperature [°C],
33#> #   max_temperature [°C], relative_humidity [%], precipitation [L/m^2],
34#> #   max_precipitation_hour [L/(m^2*h)], wind_direction [°],
35#> #   max_wind_direction [°], wind_speed [m/s], max_wind_speed [m/s],
36#> #   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 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
 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#> # ℹ 145 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.12.1, GDAL 3.8.4, PROJ 9.3.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
 6#>   cidadáns para que poida ser
 7#> utilizada libremente por eles, co único compromiso de mencionar expresamente a
 8#> MeteoGalicia e á
 9#> Consellería de Medio Ambiente, Territorio e Vivenda da Xunta de Galicia como
10#> fonte da mesma cada vez
11#> que as utilice para os usos distintos do particular e privado.
12#> https://www.meteogalicia.gal/aviso-legal
13#> Warning: plotting the first 9 out of 26 attributes; use max.plot = 26 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
 3#>   AEMET como autora de la misma.
 4#> https://www.aemet.es/es/nota_legal
 5#> Simple feature collection with 10192 features and 22 fields
 6#> Geometry type: POINT
 7#> Dimension:     XY
 8#> Bounding box:  xmin: -18.115 ymin: 27.66667 xmax: 4.323889 ymax: 43.78621
 9#> Geodetic CRS:  WGS 84
10#> # A tibble: 10,192 × 23
11#>    timestamp           service station_id station_name station_province altitude
12#>  * <dttm>              <chr>   <chr>      <chr>        <chr>                 [m]
13#>  1 2026-02-03 15:00:00 aemet   0009X      ALFORJA      TARRAGONA             406
14#>  2 2026-02-03 15:00:00 aemet   0016A      REUS  AEROP… <NA>                   71
15#>  3 2026-02-03 15:00:00 aemet   0034X      VALLS        TARRAGONA             233
16#>  4 2026-02-03 15:00:00 aemet   0042Y      TARRAGONA  … <NA>                   55
17#>  5 2026-02-03 15:00:00 aemet   0061X      PONTONS      BARCELONA             632
18#>  6 2026-02-03 15:00:00 aemet   0066X      VILAFRANCA … BARCELONA             177
19#>  7 2026-02-03 15:00:00 aemet   0073X      SITGES  VAL… <NA>                   58
20#>  8 2026-02-03 15:00:00 aemet   0076       BARCELONA  … <NA>                    4
21#>  9 2026-02-03 15:00:00 aemet   0092X      BERGA  INST… <NA>                  682
22#> 10 2026-02-03 15:00:00 aemet   0106X      BALSARENY    BARCELONA             361
23#> # ℹ 10,182 more rows
24#> # ℹ 17 more variables: temperature_soil [°C], temperature_soil_20 [°C],
25#> #   temperature_soil_5 [°C], temperature [°C], temperature_dew_point [°C],
26#> #   min_temperature [°C], max_temperature [°C], relative_humidity [%],
27#> #   precipitation [L/m^2], wind_direction [°], max_wind_direction [°],
28#> #   max_wind_speed [m/s], wind_speed [m/s], insolation [h],
29#> #   atmospheric_pressure [hPa], snow_cover [cm], geometry <POINT [°]>