layer_adjacency: Adjacency Matrix from a Raster Layer.

Description Usage Arguments Value

Description

This returns the (sparse) Matrix giving the adjacency matrix of cells in layer.

Usage

1
2
layer_adjacency(layer, from = which(raster::values(!is.na(layer))),
  to = from, directions = 4, normalize = FALSE)

Arguments

layer

A Raster* object.

from

The indices of the cells corresponding to rows in the output matrix. [default: non-NA cells]

to

The indices of the cells corresponding to columns in the output matrix. [default: same as from]

directions

the number of directions in which cells should be connected: 4 (rook's case), 8 (queen's case), 16 (knight and one-cell queen moves), or 'bishop' to connect cells with one-cell diagonal moves. Or a neigborhood matrix (see raster::adjacent). [default: 4]

normalize

If TRUE, normalize rows to sum to 1.

Value

A sparse Matrix M, where M[i,j] is equal to 1 if cell from[i] is adjacent to to[j], and is 0 otherwise.


petrelharp/landsim documentation built on May 25, 2019, 2:53 a.m.