Skip to contents

GridContiguity: queen or rook contiguity of a regular grid, cells numbered row by row. DistanceBandWeights: d1 < d <= d2 neighbours. KnnWeights: k nearest neighbours (ties to the lower index). InverseDistanceWeights: d^-power weights. KernelWeights: fixed or adaptive geographically weighted kernels as GWmodel::gw.weight. SymmetrizeWeights: union, intersection or average symmetrisation. WeightsComponents: connected components as spdep::n.comp.nb. Identical to the Python arm morie.fn.swbuild.

Usage

GridContiguity(nrow, ncol, type = "queen", torus = FALSE)

DistanceBandWeights(coords, d2, d1 = 0)

KnnWeights(coords, k)

InverseDistanceWeights(coords, power = 1, d2 = NULL, row_standardize = FALSE)

KernelWeights(
  coords,
  bw,
  kernel = "bisquare",
  adaptive = FALSE,
  diagonal = TRUE
)

SymmetrizeWeights(W, method = "union")

WeightsComponents(W)

Arguments

nrow, ncol

Grid dimensions.

type

"queen" or "rook".

torus

Wrap the grid edges.

coords

Two-column coordinates.

d1, d2

Distance band.

k

Number of neighbours.

power

Distance decay exponent.

row_standardize

Row-standardise the weights.

bw

Bandwidth (distance, or number of points when adaptive).

kernel

"gaussian", "exponential", "bisquare", "tricube" or "boxcar".

adaptive

Adaptive bandwidth.

diagonal

Keep the self weights.

W

Weights matrix.

method

"union", "intersection" or "average".

Value

Matrix or list.

References

Bivand, R. S., Pebesma, E. and Gomez-Rubio, V. (2013). Applied Spatial Data Analysis with R, 2nd ed. Springer.

Gollini, I., Lu, B., Charlton, M., Brunsdon, C. and Harris, P. (2015). GWmodel: an R package for exploring spatial heterogeneity using geographically weighted models. Journal of Statistical Software 63(17).

Examples

GridContiguity(2, 2, type = "rook")
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    1    1    0
#> [2,]    1    0    0    1
#> [3,]    1    0    0    1
#> [4,]    0    1    1    0
KernelWeights(rbind(c(0, 0), c(1, 0), c(3, 0)), 2)[1, ]
#> [1] 1.0000 0.5625 0.0000