knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Package airparis
is providing a small set of functions to access data about air quality in Ile-de-France
provided by Airparif.
library(airparis) library(tidyverse) library(ggiraph) library(lubridate) library(glue) change_dayinweek <- function(x){ x[x %in% 1] <- 8 x } data <- read_atmo() %>% mutate(isoweek = isoweek(date_time), isoyear = isoyear(date_time), weekday = change_dayinweek(wday(date_time)), daylabel = weekdays(date_time), classification = cut( score, breaks = c(0, 4.5, 7.5, Inf), labels = c("Bon", "Mediocre", "Mauvais")), tooltip = glue("{daylabel} {date_time}\nindice {score}\nclassification: {classification}") ) weektoadd <- data %>% filter(isoyear == min(isoyear)) %>% arrange(desc(isoweek)) %>% slice(1) %>% pull(isoweek) data <- mutate( data, weekid = case_when( isoyear == min(isoyear) ~ isoweek, TRUE ~ isoweek + weektoadd) ) P <- ggplot(data, aes(weekid, weekday, fill = classification, tooltip = tooltip)) + geom_tile_interactive(colour = "white") + coord_equal() + scale_y_reverse() + scale_fill_manual_interactive(name = "", values = c("Bon" = "#84bf75", "Mediocre" = "#f29400", "Mauvais" = "#d82517"), tooltip = c("Bon" = "1 <= indice <= 4", "Mediocre" = "5 <= indice <= 7", "Mauvais" = "8 <= indice <= 10")) + theme_void() + theme(legend.position = "bottom", legend.key.size = unit(0.25, "cm") ) + labs(title = "ATMO index") girafe(ggobj = P, width_svg = 6, height_svg = 2) %>% girafe_options(opts_zoom(max = 3), opts_toolbar(position = "top"))
Users can retrieve hourly and daily data measured in Ile-de-France with function
read_measures()
. The following pollutants are available:
o3
: ozonepm10
: Particulate matter with a diameter of 10 micrometers or lesspm25
: Particulate matter with a diameter of 2.5 micrometers or lessnox
: Nitrogen oxideno2
: Nitrogen dioxidelibrary(airparis) read_measures(pollutant = "pm10", station_id = "4181", dt_start = as.Date("2019-06-01"), dt_end = as.Date("2019-06-04"), granularity = "day")
The stations where measures are made are available in dataset stations
:
utils::head( stations )
Function read_atmo()
read ATMO index and return them in a data.frame.
The data is only containing the last year of daily historic. The air quality
index ranges from 1 (very good) to 10 (very bad). It characterizes in a simple
and comprehensive way the air quality of an urban agglomeration.
It is not possible to reproduce exact calculations as so2 is not available
through the web service or with read_measures().
utils::tail( read_atmo() )
Function read_alert()
read air quality alerts issued by airparif.
utils::tail( read_alert() )
Pollutants emissions are available for 2015 as data.frame (see emissions_epci
, emissions_region
, emissions_departement
):
utils::head( emissions_epci )
You can install the development version of airparis from github with:
remotes::install_github("ardata-fr/airparis")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.