Learn R Programming

openair (version 2.7-2)

importWAQN: Welsh Air Quality Network data import for openair

Description

Function for importing hourly mean Welsh Air Quality Network (WAQN) archive data files for use with the openair package. Files are imported from a remote server operated by Ricardo that provides air quality data files as R data objects.

Usage

importWAQN(
  site = "card",
  year = 2018,
  pollutant = "all",
  meta = FALSE,
  to_narrow = FALSE
)

Arguments

site

Site code of the WAQN site to import e.g. "card" is Cardiff Centre. Several sites can be imported with site = c("card", "cae6") --- to import Cardiff Centre and Hafod-yr-ynys Roadside for example.

year

Year or years to import. To import a sequence of years from 1990 to 2000 use year = 1990:2000. To import several specfic years use year = c(1990, 1995, 2000) for example.

pollutant

Pollutants to import. If omitted will import all pollutants from a site. To import only NOx and NO2 for example use pollutant = c("nox", "no2").

meta

Should meta data be returned? If TRUE the site type, latitude and longitude are returned.

to_narrow

By default the returned data has a column for each pollutant/variable. When to_narrow = TRUE the data are stacked into a narrow format with a column identifying the pollutant name.

Value

Returns a data frame of hourly mean values with date in POSIXct class and time zone GMT.

Details

The importWAQN function has been written to make it easy to import data from the Welsh Air Quality Network (WAQN) --- https://airquality.gov.wales/. Ricardo have provided .RData files (R workspaces) of all individual sites and years for the WAQN. These files are updated on a daily basis. This approach requires a link to the Internet to work.

For a list of up to date site codes and site information, see importMeta and in particular importMeta(source = "waqn").

The site codes and pollutant names can be upper or lower case. The function will issue a warning when data less than six months old is downloaded, which may not be ratified.

The function also returns wind speed (ws) and direction (wd) for more recent years derived from WRF (regional meteorological model).

See Also

See importAURN for data elsewhere in the UK and importKCL for importing comprehensive data in and around London.

Examples

Run this code
# NOT RUN {
## see what sites are available
# }
# NOT RUN {
meta <- importMeta("waqn")
# }
# NOT RUN {
## import all pollutants from Cardiff Centre
# }
# NOT RUN {
cardiff <- importWAQN(site = "card", year = 2010:2018)
# }
# NOT RUN {
## import all pollutants from two sites for 2018
# }
# NOT RUN {
all <- importWAQN(site = c("card", "cae6"), year = 2018)
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab