# gDist: calculate geostatistical distances between areas In rtop: Interpolation of Data with Variable Spatial Support

 gDist R Documentation

## calculate geostatistical distances between areas

### Description

Calculate geostatistical distances (Ghosh-distances) between areas

### Usage

``````## S3 method for class 'rtop'
gDist(object, params = list(), ...)
## S3 method for class 'SpatialPolygonsDataFrame'
gDist(object, object2 = NULL, ...)
## S3 method for class 'SpatialPolygons'
gDist(object, object2 = NULL, ...)
## S3 method for class 'list'
gDist(object, object2 = NULL, diag = FALSE, debug.level = 0, ...)
``````

### Arguments

 `object` object of class `SpatialPolygons` or `SpatialPolygonsDataFrame` with boundaries of areas; or list of discretized areas, typically from a call to `rtopDisc`; or object of class `rtop` with such boundaries and/or discretized elements (the individual areas) `params` a set of parameters, used to modify the default parameters for the `rtop` package, set in `getRtopParams`. The argument params can also be used for the other methods, through the ...-argument. `object2` an object of same type as `object`, except for `rtop`; for calculation of geostatistical distances also between the elements in the two different objects `diag` logical; if TRUE only calculate the geostatistical distances between each element and itself, only when the objects are lists of discretized areas and object2 = object or object2 = NULL `debug.level` debug.level = 0 will suppress output from the call to varMat, done for calculation of the geostatistical distances `...` other parameters, for `gDist.list` when calling one of the other methods, or for `varMat`, in which the calculations take place

### Value

If called with one list of discretized elements, a matrix with the geostatistical distances between the elements within the list. If called with two lists of discretized elements, a matrix with the geostatistical distances between the elements in the two lists. If called with `diag = TRUE`, the function returns an array of the geostatistical distance within each of the elements in the list.

If called with one `SpatialPolygons` or `SpatialPolygonsDataFrame` or the function returns a list with one matrix with geostatistical distances between the elements of the object. If called with two objects, the list will also containt a matrix of the geostatistical distances between the elements of the two objects, and an array of the geostatistical distances within the elements of the second object.

If called with an rtop-object, the function will return the object, amended with the list above.

### Note

The geostatistical distance can be seen as the average distance between points in two elements, or the average distance within points in a single element. The distance measure is also sometimes referred to as Ghosh-distance, from Ghosh (1951) who found analytical expressions for these distances between blocks with regular geometry.

The use of geostatistical distances within `rtop` is based on an idea from Gottschalk (1993), who suggested to replace the traditional regularization of variograms within block-kriging (as done in the original top-kriging application of Skoien et al (2006)) with covariances of the geostatistical distance. The covariance between two areas can then be found as `C(a1,a2) = cov(gd)` where `gd` is the geostatistical distance between the two areas `a1` and `a2`, instead of an integration of the covariance function between the two areas.

`rtop` is based on semivariograms instead of covariances, and the semivariogram value between the two areas can be found as `gamma(a1,a2) = g(gd) - 0.5 (g(gd1) + g(gd2))` where `g` is a semivariogram valid for point support, `gd1)` and `gd2` are the geostatistical distances within each of the two areas.

Jon Olav Skoien

### References

Ghosh, B. 1951. Random distances within a rectangle and between two rectangles. Bull. Calcutta Math. Soc., 43, 17-24.

Gottschalk, L. 1993. Correlation and covariance of runoff. Stochastic Hydrology and Hydraulics, 7, 85-101.

Skoien, J. O., R. Merz, and G. Bloschl. 2006. Top-kriging - geostatistics on stream networks. Hydrology and Earth System Sciences, 10, 277-287.

Skoien, J. O., Bloschl, G., Laaha, G., Pebesma, E., Parajka, J., Viglione, A., 2014. Rtop: An R package for interpolation of data with a variable spatial support, with an example from river networks. Computers & Geosciences, 67.

### Examples

``````
rpath = system.file("extdata",package="rtop")
library(sf)