knitr::opts_chunk$set(echo = TRUE) library(dplyr) library(londonair)
This package provides tools to download air quality data for London.
To install londonair
from github you need to use the devtools
package.
If you do not have devtools
installed, you will need to run the commented out line of code as well.
#install.packages("devtools") devtools::install_github("LiRogers/londonair") library(londonair)
londonair contains functions that fetch meta data and monitoring data for air quality monitoring sites across the whole of London, or for the 3 main sensor networks, the London Air Quality Network (LAQN), Breathe London, and the Air Quality England (AQE) network.
Meta data can be fetched as follows:
meta_data <- getMetaLondon() meta_data %>% head()
This gets meta data for all air quality monitoring sites across London. The equivalent functions for the 3 networks are getMetaLAQN()
, getMetaBreathe()
and getMetaAQE()
.
Hourly monitoring data can be fetched as follows:
# For all sites and species: df <- importLondon(start_date = as.Date('2019-01-01'), end_date = as.Date('2019-01-07')) # For specified sites and species: df <- importLondon(start_date = as.Date('2019-01-01'), end_date = as.Date('2019-01-07'), sites = c("BG1", "WL1", "MY1"), species = c("NO2", "PM10", "PM25")) # Providing meta data - this will speed up your code if you're making multiple calls to importLondon meta_data <- getMetaLondon() df <- importLondon(start_date = as.Date('2019-01-01'), end_date = as.Date('2019-01-07'), sites = c("BG1", "WL1", "MY1"), species = c("NO2", "PM10", "PM25"), meta_data = meta_data) df %>% head()
This will work for sites in both networks. To fetch the data from just one of the networks the equivalent functions are importLAQN()
, importBreathe()
and importAQE()
, which have the same parameters as importLondon()
.
The format of the monitoring data returned will work with the utility functions included in the OpenAir R package.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.