library(meteospain)
library(dplyr)
library(ggplot2)
library(ggforce)
library(units)
library(sf)
MeteoGalicia service offers the data of the galician automatic meteorological stations network. This network is supported and assessed by the Xunta de Galicia and the data should be trustworthy.
MeteoGalicia API offers data at different temporal resolutions:
In both, “daily” and “monthly”, a start_date
(and
optionally an end_date
) arguments must be provided,
indicating the period from which retrieve the data.
MeteoGalicia API allows specifying stations code to narrow the data
retrieved. So, a character vector of station codes can be supplied in
the stations
argument.
# last measure for all stations
<- meteogalicia_options()
api_options
api_options
# current day, only some stations
<- meteogalicia_options(
api_options resolution = 'current_day',
stations = c('10157', '14000', '10045')
)
api_options
# daily, all stations
<- meteogalicia_options(
api_options resolution = 'daily',
start_date = as.Date('2020-04-25'), end_date = as.Date('2020-05-25')
)
api_options
# monthly, some stations
<- meteogalicia_options(
api_options resolution = 'monthly',
start_date = as.Date('2020-04-01'), end_date = as.Date('2020-08-01'),
stations = c('10157', '14000', '10045')
) api_options
Accessing station metadata for MeteoGalicia is simple:
get_stations_info_from('meteogalicia')
<- meteogalicia_options(
api_options resolution = 'monthly',
start_date = as.Date('2020-01-01'),
end_date = as.Date('2020-12-31')
)<- get_meteo_from('meteogalicia', options = api_options)
galicia_2020 galicia_2020
Visually:
%>%
galicia_2020 ::drop_units() %>%
unitsmutate(month = lubridate::month(timestamp, label = TRUE)) %>%
ggplot() +
geom_sf(aes(colour = max_temperature)) +
facet_wrap(vars(month), ncol = 4) +
scale_colour_viridis_c()
%>%
galicia_2020 mutate(month = lubridate::month(timestamp, label = TRUE)) %>%
ggplot() +
geom_histogram(aes(x = precipitation)) +
facet_wrap(vars(month), ncol = 4)