Using INTAMAP

The INTAMAP system

Adding your own new methods

Although the intamap-package and the psgp-package together offer large flexibility with the use of methods, there might still be users that would like to extend the methodology further. This can easily be used in add-on packages.

For new methods of a class myClass, it is necessary or recommended to create the following new functions:

The last function is not necessary, but will make it easier to reuse estimated parameters in subsequent calls to the interpolation service. All of these functions need to be able to take an intamap object as input, and give back an intamap object with the last result added to the object. This will, for the first function, mean an element describing the estimated parameters of the new method. For the second function, an element of name predictions, either with predictions assumed to be Gaussian and names according to gstat (var1.pred and var1.var) or with names according to the request in the parameter outputWhat. methodParameters.myClass adds a string of name methodParameters, that can regenerate the estimated parameters for the method through:

> eval(parse(methodParameters))

It is also necessary to add a function with the name .onLoad that will be loaded at the start:

.onLoad <- function(libname, pkgname) {
if ("intamap" %in% rownames(utils:::installed.packages()) ) {
library(intamap)
info = matrix(c("estimateParameters",
"spatialPredict",
"methodParameters",
rep("myClass",3),rep(NA,3)),ncol = 3)
registerS3methods(info,package = "intamap",env = environment(funInMyPkg))
}
}
If the package does not have a NAMESPACE, the function should be called .first.lib.

This conditional registration of new methods makes it possible to install the new package with or without support for intamap, depending on this one being present or not. Note that this dependency is usually fixed during build or installation, so that a package built for dependency on intamap will not install on a computer where intamap is not installed, whereas a package built without intamap will not offer the functions above on a computer having intamap installed.