Function to import meta data for air quality monitoring sites. By default,
the function will return the site latitude, longitude and site type, as well
as the code used in functions like importUKAQ(), importImperial() and
importEurope(). Additional information may optionally be returned.
Usage
importMeta(
source = "aurn",
year = NULL,
pollutant = NULL,
code = NULL,
site = NULL,
site_type = NULL,
lat = NULL,
lng = NULL,
crs = 4326,
max_dist = NULL,
max_n = NULL,
all = FALSE,
duplicate = FALSE
)Arguments
- source
One or more air quality networks for which data is available through openair. Available networks include:
"aurn", The UK Automatic Urban and Rural Network."aqe", The Air Quality England Network."saqn", The Scottish Air Quality Network."waqn", The Welsh Air Quality Network."ni", The Northern Ireland Air Quality Network."local", Locally managed air quality networks in England."imperial", Imperial College London (formerly King's College London) networks."europe", European AirBase/e-reporting data.
There are two additional options provided for convenience:
"ukaq"will return metadata for all networks for which data is imported byimportUKAQ()(i.e., AURN, AQE, SAQN, WAQN, NI, and the local networks)."all"will import all available metadata (i.e.,"ukaq"plus"imperial"and"europe").
- year
If a single year is selected, only sites that were open at some point in that year are returned. If
all = TRUEonly sites that measured a particular pollutant in that year are returned. Year can also be a sequence e.g.year = 2010:2020or of length 2 e.g.year = c(2010, 2020), which will return only sites that were open over the duration.- pollutant
Character vectors used to search the metadata for the specified
sources.pollutantis case-insensitive. For example,pollutant = c("nox", "o3")will return sites which measure either NOx or O3. Can also take the shorthand"hc", will returns all hydrocarbons. Similar tocode, values are matched exactly (e.g.,pollutant = "no"will only return NO and not NO2 or NOx). Note thatpollutantonly applies to networks available throughimportUKAQ().- site, code, site_type
Character vectors used to search the metadata for the specified
sources. All ofcode,siteandsite_typeare case-insensitive.codeandsite_typeare matched exactly, butsiteis 'pattern matched' - e.g.,site = "Sunderland"andsource = "aurn"will return data for"Sunderland","Sunderland Silksworth"and"Sunderland Wessington Way"(plus any future sites with the string"Sunderland"in their name).- lat, lng
Decimal latitude (
lat) and longitude (lng) (or other Y/X coordinate if using a differentcrs). If provided, the data will be returned with adistance_kmcolumn displaying the distance of each station from the target coordinate. The data will also be automatically sorted by this column.- crs
The coordinate reference system (CRS) of the data, passed to
sf::st_crs(). By default this is EPSG:4326, the CRS associated with the commonly used latitude and longitude coordinates. Different coordinate systems can be specified usingcrs(e.g.,crs = 27700for the British National Grid). Note that non-lat/lng coordinate systems will be re-projected to EPSG:4326 for comparison with the site metadata.- max_dist, max_n
If
latandlngare provided,max_distandmax_nfurther filter the metadata.max_distdefines a maximum distance from the target coordinate in kilometers, andmax_na maximum number of sites to be returned.max_nis applied aftermax_dist.- all
When
all = FALSEonly the site code, site name, latitude and longitude and site type are imported. Settingall = TRUEwill import all available meta data and provide details (when available) or the individual pollutants measured at each site.- duplicate
Some UK air quality sites are part of multiple networks, so could appear more than once when
sourceis a vector of two or more. The default argument,FALSE, drops duplicate sites.TRUEwill return them.
Available Networks
This function imports site meta data from several networks in the UK and Europe:
"aurn", The UK Automatic Urban and Rural Network."aqe", The Air Quality England Network."saqn", The Scottish Air Quality Network."waqn", The Welsh Air Quality Network."ni", The Northern Ireland Air Quality Network."local", Locally managed air quality networks in England."imperial", Imperial College London (formerly King's College London) networks."europe", Hourly European data (Air Quality e-Reporting) based on a simplified version of the{saqgetr}package. Note that this data is only available until February 2024; seeimportEurope()for more information.
Order of Operations
This function contains various arguments which allow the user to filter the metadata before it is returned. These arguments are applied in the following order:
sourceyearpollutant(where possible)codesitesite_typemax_distmax_n
Note that max_n is not always the number of rows returned by the
function; it is the maximum number of possible sites to be returned. If
all = TRUE, multiple rows will be present per site. Further, if previous
filtering steps mean that fewer than max_n sites are remaining in the
data, max_n will have no effect.
If the combination of arguments provided results in the removal of all sites, this function will return an empty dataframe with a warning.
Data Dictionary
By default, the function will return the site latitude, longitude and site
type. If the option all = TRUE is used, much more detailed information is
returned. The following metadata columns are available in the complete
dataset:
source: The network with which the site is associated. Note that some monitoring sites are part of multiple networks (e.g., the AURN & SAQN) so the same site may feature twice under different sources.
code: The site code, used to import data from specific sites of interest.
site: The site name, which is more human-readable than the site code.
site_type: A description of the site environment.
latitude and longitude: The coordinates of the monitoring station, using the World Geodetic System (https://epsg.io/4326).
start_date and end_date: The opening and closing dates of the monitoring station. If
by_pollutant = TRUE, these dates are instead the first and last dates at which specific pollutants were measured. A missing value,NA, indicates that monitoring is ongoing.ratified_to: The date to which data has been ratified (i.e., 'quality checked'). Data after this date is subject to change.
zone and agglomeration: The UK is divided into agglomeration zones (large urban areas) and non-agglomeration zones for air quality assessment, which are given in these columns.
local_authority: The local authority in which the monitoring station is found.
provider and code: The specific provider of the locally managed dataset (e.g.,
"londonair").
References
Thanks go to Trevor Davies (WSP), Dr Stuart Grange (EMPA) and Dr Ben Barratt (Imperial College) for making these data available.
See also
the networkMap() function from the openairmaps package which can
visualise site metadata on an interactive map.
Other import functions:
importADMS(),
importAURN(),
importEurope(),
importImperial(),
importTraj(),
importUKAQ()
Examples
if (FALSE) { # \dontrun{
# Get information for the AURN
meta <- importMeta(source = "aurn")
# More detailed information
meta <- importMeta(source = "aurn", all = TRUE)
# From the AURN and SAQN
meta <- importMeta(source = c("aurn", "saqn"))
# Sites in the UK measuring SO2 or CO
meta <- importMeta(source = "ukaq", pollutant = c("so2", "co"))
# English sites within 5km of Buckingham Palace
meta <- importMeta(
source = c("aurn", "aqe", "local"),
lat = 51.50101,
lng = -0.141563,
max_dist = 5
)
} # }
