Meteoclimatic service

# use eval = NOT_CRAN in the chunks connecting to API, to avoid errors or warnings in CRAN checks
NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true")
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  purl = NOT_CRAN
)

# env keyring
withr::local_options(list("keyring_backend" = "env"))
library(meteospain)
library(ggplot2)
library(ggforce)
library(units)
library(sf)

Meteoclimatic service

Meteoclimatic is a non-professional (amateur) network of automatic meteorological stations. This network cover all Spain, but does not offer quality testing of the data.

Meteoclimatic options

Temporal resolution

Meteoclimatic API only offers aggregated data for the current day, so, in this case the resolution parameter is limited to "current_day".

Stations

Meteoclimatic API does not accept multiple stations in the same query. But it has station codes that can access the data from several stations in the same geographic area (i.e. "ES" for all stations, "ESCAT" for all stations in Catalunya, "ESCAT08" for all stations in Barcelona province). So, the stations is limited at length one.

Example

api_options <- meteoclimatic_options(stations = 'ESCAT08')
api_options

Meteoclimatic stations info

Accessing station metadata for Meteoclimatic is simple:

get_stations_info_from('meteoclimatic', options = api_options)

Meteoclimatic data

current_day_barcelona <- get_meteo_from('meteoclimatic', options = api_options)
current_day_barcelona

Visually:

current_day_barcelona |>
  units::drop_units() |>
  ggplot() +
  geom_sf(aes(colour = max_temperature)) +
  scale_colour_viridis_c()

current_day_barcelona |>
  ggplot() +
  geom_histogram(aes(x = max_relative_humidity))


Try the meteospain package in your browser

Any scripts or data that you put into this service are public.

meteospain documentation built on May 29, 2024, 1:59 a.m.