Learn R Programming

constrainedKriging (version 0.1.1)

preCKrige: 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, ...)## S3 method for class 'SpatialPoints,ANY,covmodel':
preCKrige(newdata, neighbours, model)## S3 method for class 'SpatialPointsDataFrame,ANY,covmodel':
preCKrige(newdata, neighbours, model)## S3 method for class 'SpatialPolygons,ANY,covmodel':
preCKrige(newdata, neighbours, model,
pwidth = 0, pheight = 0, napp = 1)## S3 method for class '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.fr
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 newda
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.

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:

  • covmatlist, length = n, of point-point covariance matrices.
  • posindexlist of numeric vectors, length = n, ith list component contains a vector with the row indices of the m-1 neighbours of the ith point.
  • modelobject of the class covmodel with the parameter of the used covariance function.
  • datais 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.
  • coordsmatrix, 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):
  • covmatlist of matrices, length = n, ith list component contains the approximated block-block covariance matrix of the ith polygon and its neighbourhood configuration.
  • se.covmatlist 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.
  • pixconfiglist 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.
  • pixcovmatmatrix, dim = (npix, npix), covariance matrix of the pixels.
  • modelobject of the class covmodel with the parameter of the used covariance function.
  • datais 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.
  • polygonsSpatialPolygons 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:
  • pixcenteris 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
  • rowwidthpreCKrige input argument pheight.
  • colwidthpreCKrige input argument pwidth
  • nrowspositive numeric scalar, number of rows of the pixel grid.
  • ncolspositive numeric scalar, number of columns of the pixel grid.
  • no.pix.in.polyis a numeric vector, length = m , each number indicates by how many pixels a polygon of the ith polygon configuratioin is approximated.
  • sa.polygonslogical 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.centroidsis a matrix, dim = (m,2) with the coordinates of the polygon centroids from the ith polygon neighbourhood configuration.
  • posindexis 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.polyis 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.

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.

References

See main help page of the constrainedKriging package.

See Also

CKrige

Examples

Run this code
### 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.
")
}

Run the code above in your browser using DataLab