meteospain

2025-07-02

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")

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 3716 features and 14 fields (with 696 geometries empty)
11#> Geometry type: POINT
12#> Dimension:     XY
13#> Bounding box:  xmin: -9.184586 ymin: 41.90361 xmax: -6.765224 ymax: 43.70426
14#> Geodetic CRS:  WGS 84
15#> # A tibble: 3,716 × 15
16#>    timestamp           service station_id station_name station_province altitude
17#>    <dttm>              <chr>   <chr>      <chr>        <chr>                 [m]
18#>  1 2025-07-01 07:00:00 meteog… 10045      Mabegondo    A Coruña               94
19#>  2 2025-07-01 07:00:00 meteog… 10046      Marco da Cu… A Coruña              651
20#>  3 2025-07-01 07:00:00 meteog… 10047      Pedro Murias Lugo                   51
21#>  4 2025-07-01 07:00:00 meteog… 10048      O Invernade… Ourense              1026
22#>  5 2025-07-01 07:00:00 meteog… 10049      Corrubedo    A Coruña               30
23#>  6 2025-07-01 07:00:00 meteog… 10050      CIS Ferrol   A Coruña               37
24#>  7 2025-07-01 07:00:00 meteog… 10052      Muralla      A Coruña              661
25#>  8 2025-07-01 07:00:00 meteog… 10053      Campus Lugo  Lugo                  400
26#>  9 2025-07-01 07:00:00 meteog… 10055      Guitiriz-Mi… Lugo                  684
27#> 10 2025-07-01 07:00:00 meteog… 10056      Marroxo      Lugo                  645
28#> # ℹ 3,706 more rows
29#> # ℹ 9 more variables: temperature [°C], min_temperature [°C],
30#> #   max_temperature [°C], relative_humidity [%], precipitation [L/m^2],
31#> #   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 134 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: 134 × 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#> # ℹ 124 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 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
11#> 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#> API request limit reached: Client error: (429) Too Many Requests (RFC 6585)
 3#> Trying again in 60 seconds
 4#> © AEMET. Autorizado el uso de la información y su reproducción citando a AEMET como autora de la misma.
 5#> https://www.aemet.es/es/nota_legal
 6#> Simple feature collection with 9512 features and 13 fields
 7#> Geometry type: POINT
 8#> Dimension:     XY
 9#> Bounding box:  xmin: -18.115 ymin: 27.66667 xmax: 4.323889 ymax: 43.78621
10#> Geodetic CRS:  WGS 84
11#> # A tibble: 9,512 × 14
12#>    timestamp           service station_id station_name station_province altitude
13#>    <dttm>              <chr>   <chr>      <chr>        <chr>                 [m]
14#>  1 2025-07-01 19:00:00 aemet   0009X      ALFORJA      TARRAGONA             406
15#>  2 2025-07-01 19:00:00 aemet   0016A      REUS  AEROP… <NA>                   71
16#>  3 2025-07-01 19:00:00 aemet   0034X      VALLS        TARRAGONA             233
17#>  4 2025-07-01 19:00:00 aemet   0042Y      TARRAGONA  … <NA>                   55
18#>  5 2025-07-01 19:00:00 aemet   0061X      PONTONS      BARCELONA             632
19#>  6 2025-07-01 19:00:00 aemet   0066X      VILAFRANCA … BARCELONA             177
20#>  7 2025-07-01 19:00:00 aemet   0073X      SITGES  VAL… <NA>                   58
21#>  8 2025-07-01 19:00:00 aemet   0076       BARCELONA  … <NA>                    4
22#>  9 2025-07-01 19:00:00 aemet   0092X      BERGA  INST… <NA>                  682
23#> 10 2025-07-01 19:00:00 aemet   0106X      BALSARENY    BARCELONA             361
24#> # ℹ 9,502 more rows
25#> # ℹ 8 more variables: temperature [°C], min_temperature [°C],
26#> #   max_temperature [°C], relative_humidity [%], precipitation [L/m^2],
27#> #   wind_direction [°], wind_speed [m/s], geometry <POINT [°]>