EEAaq_idw_map {EEAaq}R Documentation

Build a spatial interpolation map based on the Inverse Distance Weighting technique.

Description

EEAaq_idw_map recieves 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. It may be exported as pdf, jpeg, png, gif and html.

Usage

EEAaq_idw_map(
  data = NULL,
  pollutant = NULL,
  aggr_fun,
  bounds_level = NULL,
  distinct = FALSE,
  gradient = TRUE,
  idp = 2,
  nmax = NULL,
  maxdist = NULL,
  dynamic = FALSE,
  fill_NUTS_level = NULL,
  tile = "Esri.WorldGrayCanvas",
  save = NULL,
  filepath = NULL,
  width = 1280,
  height = 720,
  res = 144,
  delay = 1,
  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

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

bounds_level

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

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.

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.

fill_NUTS_level

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. (For instance if fill_NUTS_level = "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', 'LAU'.

tile

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

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).

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".

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


data <- EEAaq_get_data(zone_name = "Milano", NUTS_level = "LAU",
  pollutant = "PM10", from = 2023, to = 2023, ID = FALSE, verbose = TRUE)

#Monthly aggregation
t_aggr <- EEAaq_time_aggregate(data = data, frequency = "monthly",
                                aggr_fun = c("mean", "min", "max"))

#12 maps are generated, one for each month
EEAaq_idw_map(data = t_aggr, pollutant = "PM10",
aggr_fun = "mean", distinct = TRUE,
gradient = TRUE, idp = 2,
dynamic = FALSE)

#Let's try to change the parameters fill_NUTS_level and dynamic
#Now we are going to use a dataset containing PM10 concentrations
#in Milan province (NUTS 3), during 2022
data <- EEAaq_get_data(zone_name = "Milano", NUTS_level = "NUTS3",
  pollutant = "PM10", from = 2022, to = 2022)
#yearly aggregation
t_aggr <- EEAaq_time_aggregate(data = data, frequency = "yearly",
  aggr_fun = "mean")
#Let's generate one dynamic map, containing the municipalities inside the Milan province
#filled with the mean concentration value for 2022, computed via idw:
EEAaq_idw_map(data = t_aggr, pollutant = "PM10", aggr_fun = "mean",
  distinct = TRUE, gradient = FALSE, dynamic = TRUE, fill_NUTS_level = "LAU")


[Package EEAaq version 0.0.3 Index]