EEAaq_get_data {EEAaq}R Documentation

Download air quality data at european level from the EEA download service

Description

This function imports air quality datasets at european level, based on the zone, time and pollutant specifications. This function generates an EEAaq_df object, or an EEAaq_df_sfc.

Usage

EEAaq_get_data(
  zone_name = NULL,
  NUTS_level = NULL,
  pollutant = NULL,
  from = NULL,
  to = NULL,
  ID = FALSE,
  quadrant = NULL,
  polygon = NULL,
  verbose = TRUE
)

Arguments

zone_name

character vector specifying the names of the zones to consider. The reference is the NUTS and LAU nomenclature by Eurostat. See Details.

NUTS_level

character that specify the level of NUTS or LAU, to which zone_name belongs. Allowed values are 'NUTS0', 'NUTS1', 'NUTS2', 'NUTS3', 'LAU'. For further information see Details.

pollutant

the pollutants for which to download data. It may be:

  • character vector representing the short names of the pollutants to analyse. The reference is the variable Notation in the dataset pollutants provided by this package.

  • numeric vector representing the codes of the pollutants to analyse. The reference is the variable Code in the dataset pollutants provided by this package.

from

the starting point of the time window to consider. It may be:

  • integer representing the year (data are downloaded starting from the first day of the year specified)

  • character containing a specific day of the year in the format yyyy-mm-dd

to

the ending point of the time window to consider. It may be:

  • integer representing the year (data are downloaded ending at the last day of the year specified)

  • character containing a specific day of the year in the format yyyy-mm-dd

ID

logic value (T or F). If TRUE, the character specified in the parameter zone_name is the unique identifier code provided by Eurostat. The reference is the NUTS_ID column from the NUTS dataset or the LAU_ID from the LAU dataset. If FALSE (the default), the character specified in the parameter zone_name is the zone name expressed in latin characters. The reference is the NAME_LATN column from the NUTS dataset and the LAU_NAME column from the LAU dataset.

quadrant

a list of bidimensional numeric vectors containing the coordinates in WGS84 format. If the list has two elements, the function builds a square using the two coordinates as opposite extremes. If the list contains three or more elements, every point is a vertex of a polygon, in particular the convex hull of the specified points.

polygon

A sfc_POLYGON or sfc_MULTIPOLYGON class object (see https://CRAN.R-project.org/package=sf for further information), specifying the area of interest. The polygon can be imported via shapefile or other formats from the user.

verbose

logic value (T or F). If TRUE (the default) information about the function progress are printed. If FALSE no message is printed.

Details

The NUTS classification (Nomenclature of territorial units for statistics) is a hierarchical system for dividing up the economic territory of the EU and the UK. The levels are defined as follows:

Further information is available at https://ec.europa.eu/eurostat/web/nuts/background. These LAUs (Local Administrative Units) are the building blocks of the NUTS, and comprise the municipalities and communes of the European Union. For further information see https://ec.europa.eu/eurostat/web/nuts/local-administrative-units. Note that a specific name can be associated with both LAU and NUTS levels. For instance "Milano" is either a city or a NUTS 3 area in Italy. To download data referred to the city, specify zone_name = "Milano" and NUTS_level = "LAU", while to download data referred to the province, specify zone_name = "Milano" and NUTS_level = "NUTS3". One of zone_name, quadrant and polygon should always be specified by the user.

Value

A data frame of class EEAaq_df, if zone_name is specified, and of class EEAaq_df_sfc if whether the parameter quadrant or polygon is specified.

Examples



library(dplyr)
library(utils)
#Download of the PM10 data in Milan (Lombardia, Italy) during 2023.
EEAaq_get_data(zone_name = "Milano", NUTS_level = "LAU",
  pollutant = "PM10", from = 2023, to = 2023, ID = FALSE, verbose = TRUE)

#Alternatively, it is possible to obtain the same result using
#the LAU_ID of Milan and the pollutant code:
EEAaq_get_data(zone_name = "015146", NUTS_level = "LAU",
  pollutant = "PM10", from = 2023, to = 2023, ID = TRUE, verbose = TRUE)

#Another way to get the nitrogen dioxide in Milan during 2023,
#is to extract the geometry from the LAU dataset and use it with the polygon parameter:
temp <- tempfile()
download.file("https://github.com/AgostinoTassanMazzocco/EEAaq/raw/main/LAU.rds",
  temp, quiet = TRUE)
milan <- readRDS(temp) %>%
    filter(LAU_NAME == "Milano") %>%
    pull(geometry)
EEAaq_get_data(pollutant = "PM10", from = 2023, to = 2023, polygon = milan)

#Another option is to choose the exact dates, for example,
#in order to import Milan PM10 january 2023 data,
#it is possible to write:
EEAaq_get_data(polygon = milan, pollutant = "PM10", from = "2023-01-01", to = "2023-01-31")

#Spcifying the parameter quadrant, it is possible to choose
#a specific quadrant on the geographic map.
#For instance, using the points (11.5, 46.5), (10.5, 46),
#will be imported data about the air quality stations
#located inside the rectangle which has, as opposite vertexes,
#the two selected points. In this case
#PM10 and PM2.5 data are downloaded for the whole 2021:
EEAaq_get_data(pollutant = c("PM10", "PM2.5"),
  quadrant = list(c(11.5, 46.5), c(10.5, 46)),
  from = 2021, to = 2021, verbose = TRUE)


[Package EEAaq version 0.0.3 Index]