interpolate: spatial interpolation

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/interpolate.R

Description

interpolate is a function that interpolates spatial data

Usage

1
2
3
4
5
6
7
8
interpolate(observations, predictionLocations, 
            outputWhat = list(mean = TRUE, variance = TRUE), 
            obsChar = NA, methodName = "automatic", maximumTime = 30, 
            optList = list(), cv = FALSE)
interpolateBlock(observations, predictionLocations, outputWhat, 
            blockWhat = "none", obsChar = NA, methodName = "automatic", 
            maximumTime = 30, 
            optList = list())

Arguments

observations

observation data, object of class SpatialPointsDataFrame. The observation to be interpolated has to be identified through the column name value

predictionLocations

prediction locations, object of class SpatialPoints*, SpatialPixels* or SpatialGrid*, or the number of predictionLocations to be sampled from the boundaries of the observations

outputWhat

list with names what kind of output is expected, e.g. outputWhat = list(mean=TRUE,variance=TRUE, nsim = 5)

blockWhat

List defining particular output for block predictions. See createIntamapObject

obsChar

list with observation characteristics, used by some interpolation methods

methodName

name of interpolation method to be used, see spatialPredict for more details, or automatic, to let the method be decided by the program, based on maximumTime and type of variables input

maximumTime

the maximum time available for interpolation, will be compared to the result of predictTime for the requested method, or for finding the best interpolation method able to finish within this time

optList

list; further options, mainly passed to createIntamapObject as the argument params, directly as arguments, but some are used locally in interpolate and interpolateBlock:

formulaString

passed as argument to createIntamapObject, if no formulaString is given, it will default to value~1 if observations has a column named value or to col1 ~ 1 where col1 is the first column of the observations

set.seed

the possibility to pass a seed value to interpolate, to assure reproducible results also for methods relying on random numbers

methodParameters

methodParameters from an earlier run, see also methodParameters

model

defining which variogram model(s) to fit when methodName = "automap"

cv

If cross-validation should be done

Details

The functions interpolate and interpolateBlock are particularly implemented for being called by a Web Processing Server (WPS), but they can also be used interactively. The only necessary arguments are observations and predictionLocations. It is also recommended to set outputWhat, and blockWhat if necessary. If outputWhat contains nsim, the return table will also contain a number of realisations, for methods able to return simulations.

interpolate can use different interpolation methods for the result. The function will internally call the following functions which can be method specific.

An indication of available methods can be given by methods(estimateParameters) or methods(spatialPredict). The method can be set through the argument methodName, or through the built-in automatic selection method. There are different criteria that helps in selecting the right method for a particular data set. There are four methods that are available for the automatic choice: automap, psgp (from the separate package psgp) copula and transgaussian are the possibilities. First of all, if observation errors are present, the psgp method is preferred. If not, it is checked whether the data appear to deviate significantly from normality. This is assumed to be the case if any of the tests below are TRUE:

1
2
3
4
5
      test[1] = length(boxplot.stats(dataObs)$out)/length(dataObs) > 0.1
      test[2] = fivenum(dataObs)[3] - fivenum(dataObs)[2] < IQR(dataObs)/3
      test[3] = fivenum(dataObs)[4] - fivenum(dataObs)[3] < IQR(dataObs)/3
      g = boxcox(dataObs ~ 1,lambda=seq(-2.5,2.5,len=101),plotit=FALSE)$y
      test[4] = g[71] < sort(g)[91]

where fivenum defines the Tukey five number statistic and IQR finds the interquartile range of the data. If the minimum of dataObs is <= 0, min(dataObs) + sdev(dataObs) is added to all values. At last, the function calls predictTime for an estimate of the prediction time. If any of the tests above were true and the estimated prediction time for copula prediction is below maximumTime, the copula method is chosen. If any of the tests were TRUE and the estimated prediction time is too long, transGaussian kriging is chosen, as long as all values are above zero. If any of the tests are true for a set of observations with negative or zero-values, automap is chosen, but a warning is issued.

The element methodParameters in the object being returned is a string that makes it possible to regenerate the variogram model or the copula parameters in createIntamapObject. This is particularly useful when the function is called through a WPS, when the element with the estimated parameters cannot be preserved in a state that makes it possible to use them for a later call to interpolate.

The possibility for doing parallel processing is enabled for some of the main methods. To be able to take advantage of multiple CPUs on a computer, the package doParallel must be downloaded, additionally the parameter nclus must be set to a value larger than 1. Parallel computation is not taken into account when estimating the prediction times.

Value

An intamap object, which is a list with elements, see intamap-package. The exact number and names of these elements might vary due to different methods applied, but the list below shows the most typical:

observations

the observations, as a Spatial*DataFrame

predictionLocations

the prediction locations, as a Spatial-object

formulaString

the relationship between independent and dependent variables, value or obs used if not given

outputWhat

a list of the prediction types to return

anisPar

the estimated anisotropy parameters

variogramModel

the estimated parameter for the method, can also be e.g. copulaParams for the copula method or inverseDistancePower for inverse distance power method.

methodParameters

a string, that when parsed, can be used to regenerate the variogram model or copula parameters. Useful for repeated calls to interpolate when it is not necessary to reestimate the parameters.

predictions

a Spatial*DataFrame with predictions, for most methods with a format equal to the output from krige with predicted mean and variance as var1.pred and var1.var

outputTable

a matrix, organized in a convenient way for the calling WPS; first row: x-coordinates, second row: y-coordinates; further rows: output elements as specified by outputWhat

processDescription

some textual descriptions of the interpolation process, including warnings

Author(s)

Edzer Pebesma

References

Pebesma, E., Cornford, D., Dubois, G., Heuvelink, G.B.M., Hristopulos, D., Pilz, J., Stohlker, U., Morin, G., Skoien, J.O. INTAMAP: The design and implementation f an interoperable automated interpolation Web Service. Computers and Geosciences 37 (3), 2011.

See Also

createIntamapObject, estimateParameters, spatialPredict, intamap-package

Examples

1
2
3
4
5
6
7
data(meuse)
coordinates(meuse) = ~x+y
meuse$value = meuse$zinc
data(meuse.grid)
gridded(meuse.grid) = ~x+y
x = interpolate(meuse, meuse.grid, list(mean=TRUE, variance=TRUE))
summary(t(x$outputTable))

jskoien/intamap documentation built on March 19, 2018, 10:14 a.m.