preCKrige {constrainedKriging}  R Documentation 
Spatial VarianceCovariance Matrices for Sets of Points and Polygons
Description
The function preCKrige
computes (approximated) spatial
variancecovariance matrices for userdefined sets of points or polygons
(blocks) of any shape for twodimensional isotropic random fields. The
areas of a set of polygons (polygon neighbourhood configuration) are
approximated by pixels and the blockblock covariances are approximated by
averaging covariances between the pixels used to approximate the polygons.
The object returned by preCKrige
is needed by CKrige
for computing spatial point or block predictions by constrained,
covariancematching constrained or universal (external drift) Kriging.
Usage
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, ncores = 1L,
fork = !identical( .Platform[["OS.type"]], "windows"))
## S4 method for signature 'SpatialPolygonsDataFrame,ANY,covmodel'
preCKrige(newdata, neighbours,
model, pwidth = 0, pheight = 0, napp = 1, ncores = 1L,
fork = !identical( .Platform[["OS.type"]], "windows"))
Arguments
newdata 
either an object of the class
“ 
neighbours 
a list of length n with integer vectors as
components. n is equal to the number of points if
The ith list component defines the neighbours of the ith
point or ith polygon (block) in See the second example below where the function 
model 
an object of class “ 
... 
further arguments if 
pwidth 
a positive numeric scalar, defines the width of the pixels used to approximate the polygon (block) areas. 
pheight 
a positive numeric scalar, defines the height of the pixels used to approximate the polygon (block) areas. 
napp 
a positive integer scalar. 
ncores 
a positive integer scalar with the number of CPUs to use for parallel computations. 
fork 
a logical scalar to control whether parallel
computations are done by forking using 
Details
If the object newdata
is of class
“SpatialPolygonsDataFrame
” or
“SpatialPolygons
” then
preCKrige
searches the
polygon neighbourhood configuration (defined by neighbours
)
with the largest bounding box and generates a pixel grid that
completely covers the largest bounding box. Subsequently, the
covariance matrix of this set of pixels is calculated by the
spatialCovariance package and the polygon (block) areas of each
polygon neighbourhood configuration are approximated by intersecting
the polygons with the shifted pixel grid, which yields a pixel
representation of the polygon neighbourhood configuration. Finally,
the blockblock covariances of the polygons are approximated by
averaging the covariances of the pixel representation of the
polygon neighbourhood configuration.
By default, napp = 1
, which means that the approximation of the
blockblock variancecovariance matrix for each polygon neighbourhood
configuration is computed just once. If napp
> 1 the
approximation of the blockblock variancecovariance matrix for one
polygon neighbourhood configuration is based on the mean of
napp
repetitions of the approximation 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 pixel
representation of the polygon neighbourhood configuration. Large
values of the argument napp
increases the computation time.
There is a plot method plot.preCKrigePolygons
for
preCKrige
output objects of class
“preCKrigePolygons
” to visually control the polygon
(block) area approximation by the pixels.
Value
preCKrige
returns an S4 object, either of class
“preCKrigePolygons
” if
newdata
is of class
“SpatialPolygons
” or
“SpatialPolygonsDataFrame
” or an S4 object of class
“preCKrigePoints
” if
newdata
is of class “SpatialPoints
” or
“SpatialPointsDataFrame
”.
Notation:
n  number of polygons or points in newdata ,
i = 1, ..., n 
m_i  size of point or polygon neighbourhood configuration 
m_i = 1 + number of (defined) neighbours of the ith point
or ith polygon 

r_{\mathrm{pix}}  number of pixel grid rows 
c_{\mathrm{pix}}  number of pixel grid columns 
n_{\mathrm{pix}}  number of pixels in pixel grid
n_{\mathrm{pix}} = r_{\mathrm{pix}} \cdot c_{\mathrm{pix}} 
An object of class “preCKrigePoints
” contains the
following slots:
covmat 
a list of length 
posindex 
a list of length 
model 
an object of class “ 
data 
a data frame, which is the 
coords 
a matrix with 
An object of class “preCKrigePolygons
” contains the
following slots:
covmat 
a list of length 
se.covmat 
a list of length 
pixconfig 
a list of lists of length 
pixcovmat 
a matrix, 
model 
an object of class “ 
data 
a data frame which is the 
polygons 
a 
The i
th component of pixconfig
is a list with the
following 10 components:
pixcenter 
a matrix with 
rowwidth 

colwidth 

nrows 
a numeric scalar with number of rows

ncols 
a numeric scalar with number of columns

no.pix.in.poly 
a numeric vector of length 
sa.polygons 
a logical vector of length 
polygon.centroids 
a matrix with 
posindex 
an integer vector of length 
pix.in.poly 
is a binary matrix with 
Note
A polygon (block) is treated as point if the polygon area is smaller than the (defined) pixel area or if all pixel centroids 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 shares the largest area.
The pointpoint correlations are calculated via the internal function
CorrelationFct
(this function implements a subset of the
covariance models available previously in the function
CovarianceFct
of the archived package RandomFields,
version 2.0.71) and the pointblock covariances are calculated by the C
function PointRectCov
of the package.
Author(s)
Christoph Hofer, christoph.hofer@alumni.ethz.ch
References
Hofer, C. and Papritz, A. (2011). constrainedKriging: an Rpackage for customary, constrained and covariancematching constrained point or block Kriging. Computers & Geosciences. 37, 1562–1569, doi:10.1016/j.cageo.2011.02.009
See Also
Examples
### first example
### load data
data(meuse, package = "sp")
data(meuse.blocks)
### plot blocks
plot(meuse.blocks)
### compute the approximated block variance of each block in meuse.blocks
### without any neighbouring blocks (default, required for in universal
### and constrained Kriging) for an exponential covariance function without
### a measurement error, a nugget = 0.15 (micro scale white noise process),
### a partial sill variance = 0.15 and a scale parameter = 192.5
### approximation of block variance by pixel of size 75m x 75m
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 for block 59
plot(preCK_1, 59)
### second example
### define neighbours by using the poly2nb function
### of the spdep package
if(!requireNamespace("spdep", quietly = TRUE)){
stop("install package spdep to run example")
}
neighbours < spdep::poly2nb(meuse.blocks)
class(neighbours)
### neighbours should be an object of 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", nugget = 0.05, variance = 0.15,
scale = 192.5), pwidth = 75, pheight = 75)
### plot block approximation of block 59 and its
### block neighbours
plot(preCK_2, 59)