preCKrige {constrainedKriging}R Documentation

Spatial Variance-Covariance Matrices for Points and Polygons of any Shape

Description

The function preCKrige provides (approximated) spatial variance-covariance matrices for user defined sets of polygons (blocks) of any shape or points for two-dimensional isotropic random fields. The polygon (block) areas of a set of polygons (polygon neighbourhood configuration) are approximated by pixels and the block-block 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, covariance-matching 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)

## S4 method for signature 'SpatialPolygonsDataFrame,ANY,covmodel'
preCKrige(newdata, neighbours, model,
pwidth = 0, pheight = 0, napp = 1)

Arguments

newdata

either an object of the classes “SpatialPoints” or
SpatialPointsDataFrame” that contains the point coordinates and if necessary additional point information (covariates) stored in the data.frame of the SpatialPointsDataFrame object, or an object of the classes
SpatialPolygons” or “SpatialPolygonsDataFrame” with the coordinates of the polygons (block) and if necessary additional polygon information (covariates) stored in the data frame of the SpatialPointsDataFrame object.

neighbours

list of n integer vectors, where n = number of points if newdata is an object of the classes “SpatialPoints” or “SpatialPointsDataFrame” or n = number of polygons (blocks) if newdata is an object of the classes “SpatialPolygons” or “SpatialPolygonsDataFrame”. The ith list component define the neighbours of the ith point or polygon (block) in newdata. If newdata is an object of the classes “SpatialPolygons” or
SpatialPolygonsDataFrame” each list component contains the list indices of the neighbour polygons of the polygon list newdata@polygons. If newdata is an object of the classes “SpatialPoints” or
SpatialPointsDataFrame” each list component contains the row indices of the neighbour points from the point-coordinates matrix. The ith list component is set to integer(0) if the ith polygon or point have no (defined) neighbours. By default, the points or polygons have no neighbours. See the second example where the function poly2nb of the spedp package is used to build such a neighbours list.

model

object of class “covmodel”. The object contains the parameter of the isotropice covariance function, generated by the function covmodel.

...

further arguments if newdata is of class “SpatialPolygons” or
SpatialPolygonsDataFrame

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. napp > 1 reduces the block-block variance-covariance approximation error. By default, napp = 1. See details.

Details

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 block-block covariances are approximated by averaging the pixel covariances of the approximated polygon (block) areas.

By default, napp = 1 means that the approximation of the block-block variance-covariance 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 block-block variance-covariance matrix for one polygon neighbourhood configuration is based on the mean of napp approximated block-block variance-covariance matrices in order to reduce the approximation error. Each of the napp block-block variance-covariance 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.

Value

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 point-point covariance matrices.

posindex

list of numeric vectors, length = n, ith list component contains a vector with the row indices of the m-1 neighbours of the ith point.

model

object of the class “covmodel” with the parameter of the used covariance function.

data

is the data frame of the SpatialPointsDataFrame object. This data frame is used to build the target points design matrix for spatial interpolation by the CKrige function. data is empty, dim(data) = (0,0), if newdata is an object of the class “SpatialPoints”.

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 block-block 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 block-block covariances of the ith polygon and its neighbourhood configuration, values are NaN if preCKrige argument napp = 1. See details.

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 pixconfig are described below.

pixcovmat

matrix, dim = (npix, npix), covariance matrix of the pixels.

model

object of the class “covmodel” with the parameter of the used covariance function.

data

is the data frame of the SpatialPolygonsDataFrame object. This data frame is used to build the target polygons (blocks) design matrix for spatial interpolation by the CKrige function. data is empty, dim(data) = (0, 0), if newdata is an object of the class “SpatialPolygons”.

polygons

SpatialPolygons object. A list (length = n) with the polygons of the newdata object.


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 2napp

rowwidth

preCKrige input argument pheight.

colwidth

preCKrige input argument pwidth

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 neighbours argument of the preCKrige function.

pix.in.poly

is a binary matrix, dim = (npix, m). pix.in.poly[k,l] = 1 indicate that the centroid of the kth pixel lies in the area of the lth polygon and
pix.in.poly[k,l] = 0 indicate that the kth pixel centroid does not lie in the area of the lth polygon.

Note

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 point-point covariances are calculated via the CovarianceFct of the RandomFields package and the point-block covariances are calculated in C.

Author(s)

Christoph Hofer, christoph.hofer@alumni.ethz.ch

References

See main help page of the constrainedKriging package.

See Also

CKrige

Examples

## 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 variance-covariance
### 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)

[Package constrainedKriging version 0.2.4 Index]