EEAaq_idw_map: Build a spatial interpolation map based on the Inverse...

View source: R/EEAaq_idw_map.R

EEAaq_idw_mapR Documentation

Build a spatial interpolation map based on the Inverse Distance Weighting technique. The function EEAaq_idw_map requires as input a EEAaq_taggr_df or a EEAaq_taggr_df_sfc class object and produces a spatial interpolation map. Depending on the time frequency of the aggregation, multiple maps are generated, one for each timestamp. Interpolation maps may be exported as pdf, jpeg, png, gif and html.

Description

Build a spatial interpolation map based on the Inverse Distance Weighting technique. The function EEAaq_idw_map requires as input a EEAaq_taggr_df or a EEAaq_taggr_df_sfc class object and produces a spatial interpolation map. Depending on the time frequency of the aggregation, multiple maps are generated, one for each timestamp. Interpolation maps may be exported as pdf, jpeg, png, gif and html.

Usage

EEAaq_idw_map(
  data = NULL,
  pollutant = NULL,
  aggr_fun,
  distinct = FALSE,
  gradient = TRUE,
  idp = 2,
  nmax = NULL,
  maxdist = NULL,
  NUTS_filler = NULL,
  NUTS_extborder = NULL,
  NUTS_intborder = NULL,
  dynamic = FALSE,
  tile = "Esri.WorldGrayCanvas",
  filepath = NULL,
  width = 1280,
  height = 720,
  res = 144,
  delay = 1,
  save = NULL,
  verbose = TRUE
)

Arguments

data

an object of class EEAaq_taggr_df or EEAaq_taggr_df_sfc, which is the output of the EEAaq_time_aggregate function.

pollutant

vector containing the pollutant for which to build the map. It must be one of the pollutants contained in data.

aggr_fun

character containing the aggregation function to use for computing the interpolation. It must be one of the statistics contained in data.

distinct

logic value (T or F). If TRUE, each map generated is printed and saved in distinct pages (for instance if data has a monthly frequency in a yearly time window, 12 distinct plots are generated). If FALSE (the default), the maps are printed in a single page.

gradient

logic value (T or F). If TRUE (the default) the maps generated are colored with a continuous color scale. If FALSE, the color scale is discrete.

idp

numeric value that specify the inverse distance weighting power. For further information see idw.

nmax

numeric value; specify the number of nearest observations that should be used for the inverse distance weighting computing, where nearest is defined in terms of the space of the spatial locations. By default, all observations are used. For further information see idw

maxdist

numeric value; only observations within a distance of maxdist from the prediction location are used for the idw computation. By default, all observations are used. If combined with nmax, both criteria apply.

NUTS_filler

character containing the NUTS level or LAU for which to aggregate the idw computing, in order to obtain a uniform coloring inside each area at the specified level. Recall that 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:

  • NUTS 0: the whole country

  • NUTS 1: major socio-economic regions

  • NUTS 2: basic regions for the application of regional policies

  • NUTS 3: small regions for specific diagnoses

  • LAU: municipality

For instance if NUTS_filler = "LAU", each municipality is filled by the mean value of the pollutant concentration, computed by the idw, of each pixel inside the respective municipality). Allowed values are 'NUTS0', 'NUTS1', 'NUTS2', 'NUTS3', and 'LAU'.

NUTS_extborder

character containing the NUTS level or LAU for which draw external boundaries. Admissible values are 'NUTS0', 'NUTS1', 'NUTS2', 'NUTS3', 'LAU'.

NUTS_intborder

character containing the NUTS level or LAU for which draw internal boundaries. Admissible values are 'NUTS0', 'NUTS1', 'NUTS2', 'NUTS3', 'LAU'.

dynamic

logic value (T or F). If TRUE the function creates a Leaflet map widget using htmlwidgets (for further information see leaflet). If FALSE (the default) the maps generated are static.

tile

character representing the name of the provider tile. To see the full list of the providers, run providers. For further information see addProviderTiles.

filepath

a character string giving the file path.

width, height

the width and the height of the plot, expressed in pixels (by default width = 1280, height = 720). This parameters are available only for save 'jpeg', 'png' and 'gif'. For further information see png or jpeg.

res

the nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer (by default res = 144). This parameter is available only for save 'jpeg', 'png'. For further information see png or jpeg.

delay

numeric value specifying the time to show each image in seconds, when save = "gif".

save

character representing in which extension to save the map. Allowed values are 'jpeg', 'png', 'pdf' (if dynamic = FALSE), 'gif' (if dynamic = FALSE & distinct = TRUE), 'html' (if dynamic = TRUE).

verbose

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

Details

EEAaq_idw_map create a spatial interpolation map, based on the Inverse Distance Weighting method (Shepard 1968). This method starts from the available georeferenced data and estimates the value of the variable in the points where it's unknown as a weighted average of the known values, where weights are given by an inverse function of the distance of every point from the fixed stations. The greater the distance of a point from a station, the smaller the weight assigned to the values of the respective station for the computing of that unknown point. Given the sampling plan s_{i} for i=1,...,n, which represent the location of the air quality stations, the pollutant concentration value Y(s_i)=Y_i represents the value of the pollutant concentration detected by the site s_i and u is the point for which the value of the concentration in unknown.

\hat{Y}(u) = \sum_{i=1}^{n} Y_i \omega_i(u),

where

\omega_i(u) = \frac{g(d(s_i,u))}{\sum_{i=1}^{n}g(d(s_i,u))}

represent the weights assigned to each location s_i and d(s_i,u) is the distance between u and s_i.

Value

cosa restituisce la funzione

Examples

## Not run: 
`%>%` <- dplyr::`%>%`
### Filter all the stations installed in the city (LAU) of Milano (Italy)
IDstations <- EEAaq_get_stations(byStation = FALSE, complete = FALSE)
IDstations <- IDstations %>%
                dplyr::filter(LAU_NAME == "Milano") %>%
                dplyr::pull(AirQualityStationEoICode) %>%
                unique()
### Download NO2 measurement for the city of Milano from January 1st
###   to December 31st, 2023
data <- EEAaq_get_data(IDstations = IDstations, pollutants = "NO2",
                       from = "2023-01-01", to = "2023-01-31",
                       verbose = TRUE)

### Monthly aggregation: compute station-specific monthly minimum,
###   average, and maximum NO2 concentrations
t_aggr <- EEAaq_time_aggregate(data = data, frequency = "monthly",
                               aggr_fun = c("mean", "min", "max"))

### Static IDW interpolation of the average NO2 concentrations for the
###   whole Lombardy region (NUTS_extborder = "NUTS2"). Interpolated values
###   are then aggregated at the provincial level (NUTS_filler = "NUTS3")
EEAaq_idw_map(data = t_aggr, pollutant = "NO2", aggr_fun = "mean",
              distinct = TRUE, gradient = FALSE,
              dynamic = FALSE,
              NUTS_filler = "NUTS3",
              NUTS_extborder = "NUTS2")

### Dynamic IDW interpolation map (interactive leafleat) of the average
###   NO2 concentrations for the whole Lombardy region
###   (NUTS_extborder = "NUTS2"). Interpolated values are then aggregated
###   at the municipal level (NUTS_filler = "LAU")
EEAaq_idw_map(data = t_aggr, pollutant = "NO2", aggr_fun = "mean",
              distinct = TRUE, gradient = FALSE,
              dynamic = TRUE,
              NUTS_filler = "LAU",
              NUTS_extborder = "NUTS2",
              NUTS_intborder = "LAU")

## End(Not run)


EEAaq documentation built on April 3, 2025, 11:16 p.m.

Related to EEAaq_idw_map in EEAaq...