preCKrige {constrainedKriging}  R Documentation 
The function preCKrige
provides (approximated) spatial
variancecovariance matrices for user defined sets of polygons (blocks) of
any shape or points for twodimensional isotropic random fields. The
polygon (block) areas of a set of polygons (polygon neighbourhood
configuration) are approximated by pixels and the blockblock covariances
are approximated by averaging the pixel covariances of the approximated
polygon (block) areas.
The returned object of preCKrige
is, in general, needed
by CKrige
for spatial point or block interpolation by
constrained, covariancematching constrained or universal (external drift)
kriging.
preCKrige( newdata, neighbours, model, ... ) ## S4 method for signature 'SpatialPoints,ANY,covmodel' preCKrige(newdata, neighbours, model) ## S4 method for signature 'SpatialPointsDataFrame,ANY,covmodel' preCKrige(newdata, neighbours, model) ## S4 method for signature 'SpatialPolygons,ANY,covmodel' preCKrige(newdata, neighbours, model, pwidth = 0, pheight = 0, napp = 1) ## S4 method for signature 'SpatialPolygonsDataFrame,ANY,covmodel' preCKrige(newdata, neighbours, model, pwidth = 0, pheight = 0, napp = 1)
newdata 
either an object of the classes
“ 
neighbours 
list of n integer vectors, where n = number
of points if 
model 
object of class “ 
... 
further arguments if 
pwidth 
positive numeric scalar, defines the width of the pixels which are used to approximate the polygon (block) area. 
pheight 
positive numeric scalar, defines the height of the pixels which are used to approximate the polygon (block) area. 
napp 
positive integer scalar. 
If the objects for newdata
are of the classes
“SpatialPolygons
” or
“SpatialPolygonsDataFrame
”, preCKrige
searches the
polygon (block) neighbourhood configuration (defined by the argument
neighbours
) with the largest bounding box and generates a pixel gird
with the same area as the largest bounding box. Subsequently, the
covariance matrix of this pixels is calculated by using the
spatialCovariance package and the polygon (block) areas of each
polygon neighbourhood configuration are approximated by the pixels.
Finally, the blockblock covariances are approximated by averaging the
pixel covariances of the approximated polygon (block) areas.
By default, napp
= 1 means that the approximation of the blockblock
variancecovariance matrix for each polygon neighbourhood configuration is
based on one specific polygon (block) area approximation defined by one
grid of pixels. If napp
> 1 the approximation of the blockblock
variancecovariance matrix for one polygon neighbourhood configuration is
based on the mean of napp
approximated blockblock
variancecovariance matrices in order to reduce the approximation error.
Each of the napp
blockblock variancecovariance approximations are
based on a new, randomly shifted pixel gird which results each time in a new
block area approximation. Large values of the argument napp
increases the computation time.
There is a plot method plot.preCKrigePolygons
for
preCKrige
output objects of the class
“preCKrige.polygons
” to visually control the polygon (block)
area approximation by the pixels.
preCKrige
returns a S4 object, either of class
“preCKrigePolygons
” if the object for the argument
newdata
is of the class “SpatialPolygons
” or
“SpatialPolygonsDataFrame
” or an S4 object of the class
“preCKrigePoints
” if the object for the argument newdata
is
of the class “SpatialPoints
” or
“SpatialPointsDataFrame
” ( see preCKrigePolygons
or preCKrigePoints
for the general structures of these
two classes).
Notation:
n = total number of polygons or points
i = 1, ..., n
m = 1 + number of (defined) neighbours of the ith polygon
rpix = number of pixel grid rows
cpix = number of pixel grid columns
npix = rpix * cpix
An object of the class “preCKrigePoints
” contains the following slots:
covmat 
list, length = n, of pointpoint covariance matrices. 
posindex 
list of numeric vectors, length = n, ith list component contains a vector with the row indices of the m1 neighbours of the ith point. 
model 
object of the class “ 
data 
is the data frame of the 
coords 
matrix, dim = (n, 2) with the coordinates of the points. 
An object of the class “preCKrigePolygons
” contains the
following slots (values are accessible by the @ operator):
covmat 
list of matrices, length = n, ith list component contains the approximated blockblock covariance matrix of the ith polygon and its neighbourhood configuration. 
se.covmat 
list of matrices, length = n, ith list
component contains a matrix with the standard errors of the approximated
blockblock covariances of the ith polygon and its neighbourhood
configuration, values are

pixconfig 
list of lists, length = n, ith list component
contains at list with the information about the pixel used for the
covariance approximation of the ith polygon and its neighbours. The list
components of 
pixcovmat 
matrix, dim = (npix, npix), covariance matrix of the pixels. 
model 
object of the class “ 
data 
is the data frame of the 
polygons 
SpatialPolygons object. A list (length = n) with the
polygons of the 
The slot pixconfig
is a list, length( pixconfig
) = n, of
lists, each of length = 10, with information about the pixel grid used to
approxiamte the polygon (block) areas. The ith list of
pixconfig
contains the following 10 components:
pixcenter 
is a matrix, dim = (m,2) with the coordinates of the
pixels centroids of the pixel grid for the ith polygon
neighbourhood configuration. The dimension of the matrix is 
rowwidth 

colwidth 

nrows 
positive numeric scalar, number of rows of the pixel grid. 
ncols 
positive numeric scalar, number of columns of the pixel grid. 
no.pix.in.poly 
is a numeric vector, length = m , each number indicates by how many pixels a polygon of the ith polygon configuratioin is approximated. 
sa.polygons 
logical vector, length = m, TRUE means that the ith polygon is treated as point and FALSE means that the polygon is approximated by pixels. See section Note for more details. 
polygon.centroids 
is a matrix, dim = (m,2) with the coordinates of the polygon centroids from the ith polygon neighbourhood configuration. 
posindex 
is a numeric vector, length = m, that contains the list
indices of the ith polygon and its neighbours
defined in the ith list component of the 
pix.in.poly 
is a binary matrix, dim = (npix, m).

A polygon (block) is treated as point if the polygon area is smaller than the (defined) pixel area or if all pixel centroid of the generated pixel grid lie outside the polygon (block) area. If a pixel centroid lies inside a polygon that has a smaller area than a pixel, the pixel is allocated to the polygon (block) by which it share the largest area.
The pointpoint covariances are calculated via the
CovarianceFct
of the RandomFields package and the
pointblock covariances are calculated in C.
Christoph Hofer, christoph.hofer@alumni.ethz.ch
See main help page of the constrainedKriging package.
## Not run: ### first example ### load data data(meuse,meuse.blocks) ### plot blocks plot(meuse.blocks) ### compute the approximated block variance of each block in meuse.blocks ### without the definition of neighbours blocks (default) for an exponential ### covariance function without a measurement error, a nugget = 0.15 (micro ### scale white noise process) and a scale parameter = 192.5 preCK_1 < preCKrige(newdata = meuse.blocks, model = covmodel(modelname = "exponential", mev = 0, nugget = 0.05, variance = 0.15, scale = 192.5), pwidth = 75, pheight = 75) ### plot block approximation of block 59 plot(preCK_1, 59) ### second example ### define neighbours by using the poly2nb function ### of the spdep package if(require(spdep)) { neighbours < poly2nb(meuse.blocks) class(neighbours) ### neighbours should be an object of the class "list" class(neighbours) < "list" ### compute the approximated block variancecovariance ### matrices of each block in meuse.blocks without the ### defined block neighbours preCK_2 < preCKrige(newdata = meuse.blocks, neighbours = neighbours, model = covmodel("exponential", 0.05, 0.15, scale = 192.5), pwidth = 75, pheight = 75) ### plot block approximation of block 59 and its ### block neighbours plot(preCK_2, 59) } if(!require(spdep)) { cat("Please, install the package spdep to execute this example.\n") } ## End(Not run)