Interpolation

Data

The airquality dataset (luftqualitaet.gpkg) contains measurements of nitrogen dioxide NO₂ from 2015 for 97 monitoring sites in Switzerland. Nitrogen dioxide is produced when fuels and combustibles are burned, especially at high combustion temperatures, with road traffic being the main source. You can find more information on this here.

Exercise 1: IDW

Use the function gstat::idw to interpolate the NO₂ values using the inverse distance weighted method.

Note

The function idw needs following inputs: formula, locations and newdata

  • formula: For ordinary, simple kriging use the formula z~1 where z is the column name of the dependent variable
  • locations: A sf object with the locations of the dependent variable
  • newdata: A sf object with the locations for which the dependent variable should be calculated. Can be created with sf::st_make_grid. The cellsize arugument determins the resolution of the resuting dataset.

Optional arguments:

  • maxdist: Maximum distance to which measurements should be considered
  • nmin /nmax: Minimum and maxximum number of measurements to consider
  • idp the inverse distance weighting power

Play around with maxdist, nmin /nmaxand idp. Convert the resulting sf object to a raster (find out how!) and visualize the result.

Exercise 2: Nearest Neighbour

Another simple option for interpolation is the nearest neighbour approach, that we can recreate using voronoi polygons. Use the approach described in Exercise 2: Voronoi to create voronoi polygons. Turn the resulting sfc object to sf using st_as_sf, then use st_join to add the measured NO2 values the polygons.

Visualize the result.