Skip to contents

As spdep::poly2nb: queen neighbours share at least one boundary vertex within snap in both coordinates, rook neighbours at least two. Polygons are two-column coordinate matrices; a repeated closing vertex is ignored.

Usage

PolygonContiguity(polygons, queen = TRUE, snap = sqrt(.Machine$double.eps))

Arguments

polygons

List of coordinate matrices.

queen

Queen (one shared point) or rook (two).

snap

Coordinate tolerance.

Value

Binary matrix.

Examples

sq <- function(x, y) cbind(c(x, x + 1, x + 1, x), c(y, y, y + 1, y + 1))
PolygonContiguity(list(sq(0, 0), sq(1, 0), sq(1, 1)), queen = FALSE)
#>      [,1] [,2] [,3]
#> [1,]    0    1    0
#> [2,]    1    0    1
#> [3,]    0    1    0