interpolationError: Interpolate many maps at once, compare them to the original...

Description Usage Arguments Value Author(s) Examples

View source: R/interpolationError.R

Description

This function calls interpolate, then it compares the result plume-and-location-wise to the original and summarises the resulting error values.

Usage

1
2
3
4
interpolationError(simulations, locations, kinds, 
  fun_interpolation = NA, fun_error = NA, 
  fun_Rpl = NA, fun_Rpl_cellStats = "mean", fun_l = NA, 
  tmpfile = "tmp_interpolationError", overwrite = FALSE, chunksize = 1e+7)

Arguments

simulations

Simulations

locations

indices of locations to be used as input; multiple and invalid values are ignored

kinds

layer of the values of simulations to be used; interpolation can only be applied to one layer: if kinds is a vector, only the first entry is used

fun_interpolation

interpolation function, must have the parameters y, data, newdata (form as for krige0). All other parameters need default values, e.g. the model of krige0 that can be set by replaceDefault with
type = "interpolation_fun.interpolate".

fun_error

function to compare original and interpolated map location-and-plume-wise; must have a parameter x, then x[1] is the original and x[2] the interpolated value; it is forwarded to simulationsApply as fun_pl, therefore it has to fulfil all requirements for such functions; interpolationErrorFunctions provides some common examples

fun_Rpl

function to summarise the location-and-plume-wise errors, is forwarded to simulationsApply as fun_Rpl; if input does not fit into memory, it cannot be applied (causes warning)

fun_Rpl_cellStats

alternative function to summarise the location-and-plume-wise errors, is forwarded to simulationsApply as fun_Rpl_cellStats

fun_l

function to compare original and interpolated location-wise, i.e. generate one global map that takes into account all plumes; must have parameter x, then x[,1] refers to the original and x[,2] to the interpolated values; it is forwarded to simulationsApply as fun_pl, therefore it has to fulfil all requirements for such functions; interpolationErrorFunctions provides some common examples

tmpfile

filename for the raster file in case the result does not fit into memory; if FALSE the function stops with a warning and does not create a file

overwrite

boolean, if the file at tmpfile may be overwritten

chunksize

maximal number of cells to be processed at once – forwarded to blockSize inside

Value

List of values and rasters (of same dimension as the values of the simulations):

"cost": result of fun_Rpl if available (if not, warning), else result of fun_Rpl_cellStats (to guarantee that there is always a value)

"cost_cellStats": result of fun_Rpl_cellStats (if this is not in "cost")

"error_locationsplumes": raster, result of fun_error

"interpolated": result of the interpolation with fun_interpolation

"costLocations": result of fun_l

Author(s)

kristina.helle@uni-muenster.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  data(radioactivePlumes)
  ## preparation
  idw0z = replaceDefault(idw0, newDefaults = list(
    formula = z ~ 1))[[1]]
  sampleLocations100 = sample.int(nLocations(radioactivePlumes), 100)
  fun_Rpl_mean = function(x, nout = 1){ 
    mean(x[,1], na.rm = TRUE)
  }
  ## compute interpolation error 
  ## Not run: 
  ## takes some seconds
    interpolationError_delineation <- interpolationError(
      simulations = radioactivePlumes,
      locations = sampleLocations100,
      kinds = 2,
      fun_interpolation = idw0z,
      fun_error = delineationError,
      fun_Rpl = fun_Rpl_mean,
      fun_Rpl_cellStats = "mean",
      fun_l = delineationErrorMap
    )    
  # cost  
  interpolationError_delineation[["cost_cellStats"]]  
  ## plot error map
  interpolationErrorMaps = radioactivePlumes
  interpolationErrorMaps@values = 
    stack(radioactivePlumes@values[[2]],
          interpolationError_delineation[["interpolated"]],
          interpolationError_delineation[["error_locationsplumes"]][[1]])
  interpolationErrorMapsSDF = extractSpatialDataFrame(interpolationErrorMaps, plumes = 1:5) 
  interpolationErrorMapsSDF@data$costMap = interpolationError_delineation[["costLocations"]]
  # original, interpolated, error (1: overestimation, 5: underestimation)
  spplotLog(interpolationErrorMapsSDF, zcol = 1:15)
  # error summary - mean error of all plumes
  spplot(interpolationErrorMapsSDF, zcol = "costMap")

  
## End(Not run)

sensors4plumes documentation built on May 1, 2019, 10:27 p.m.