gridadjacencymatrix {spatstat.sparse}R Documentation

Create Adjacency Matrix for Spatial Grid

Description

Given the dimensions of a rectangular grid of points, this command creates the adjacency matrix for the corresponding neighbourhood graph, whose vertices are the grid points, and whose edges are the joins between neighbouring grid points.

Usage

gridadjacencymatrix(dims, across = TRUE, down = TRUE, diagonal=TRUE)

Arguments

dims

Grid dimensions. An integer, or a vector of two integers. First entry specifies the number of points in the y direction.

across

Logical value equal to TRUE if horizontal neighbours should be joined.

down

Logical value equal to TRUE if vertical neighbours should be joined.

diagonal

Logical value equal to TRUE if diagonal neighbours should be joined.

Details

If N = prod(dims) is the total number of grid points, then the result is an N * N sparse matrix with logical entries equal to TRUE if the corresponding grid points are joined.

Value

A sparse matrix.

Author(s)

Adrian Baddeley.

Examples

  gridadjacencymatrix(c(2,3))  

[Package spatstat.sparse version 3.1-0 Index]