library(meteospain)
library(ggplot2)
library(ggforce)
library(sf)
RIA service offers the data of the andalucian automatic meteorological stations network. This network is supported and assessed by the Junta de Andalucía and the data should be trustworthy.
RIA 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.
RIA API needs station codes and province codes to retrieve the data. Sadly, RIA doesn’t provide unique station codes, and the uniqueness comes with the province id and station code together. So, to narrow the data retrieving to the desired stations they must be provided as a character vector of “province_id-station_code” values (i.e. “14-2”) for the stations
argument. Calling get_stations_info_from('ria', ria_options)
will show the station correct codes in the station_id
column to take as reference.
# default, daily for yesterday
<- ria_options()
api_options
api_options
# daily, only some stations
<- ria_options(
api_options resolution = 'daily',
stations = c('14-2', '4-2')
)
api_options
# monthly, some stations
<- ria_options(
api_options resolution = 'monthly',
start_date = as.Date('2020-04-01'), end_date = as.Date('2020-08-01'),
stations = c('14-2', '4-2')
) api_options
Accessing station metadata for RIA is simple:
get_stations_info_from('ria', ria_options)
<- ria_options(
api_options resolution = 'daily',
start_date = as.Date('2020-04-25')
)<- get_meteo_from('ria', options = api_options)
galicia_20200425 galicia_20200425
Visually:
%>%
galicia_20200425 ::drop_units() %>%
unitsggplot() +
geom_sf(aes(colour = max_temperature)) +
scale_colour_viridis_c()
%>%
galicia_20200425 ggplot() +
geom_histogram(aes(x = precipitation))