findLinearNeighbours: Find Neighbouring Cells

Description Usage Arguments Value Examples

View source: R/cm_findLinearNeighbours.R

Description

Given a vector of cell IDs (cell.ids) and a vector (blocks), which defines the number of blocks / cells per dimension, a list of all combinations of (linearly) neighbouring cells around each element of cell.ids is returned.

Usage

1
findLinearNeighbours(cell.ids, blocks, diag = FALSE)

Arguments

cell.ids

[integer]
Vector of cell IDs (one number per cell) for which the neighbouring cells should be computed.

blocks

[integer]
The number of blocks per dimension.

diag

[logical(1)]
logical, indicating whether only cells that are located parallel to the axes should be considered (diag = FALSE) as neighbours. Alternatively, one can also look for neighbours that are located diagonally to a cell. The default is diag = FALSE.

Value

[list of integer(3)].
List of neighbours. Each list element stands for a combination of predecessing, current and succeeding cell.

Examples

1
2
3
4
5
6
7
8
cell.ids = c(5, 84, 17, 23)
blocks = c(5, 4, 7)

# (1) Considering diagonal neighbours as well:
findLinearNeighbours(cell.ids = cell.ids, blocks = blocks, diag = TRUE)

# (2) Only consider neighbours which are parellel to the axes:
findLinearNeighbours(cell.ids = cell.ids, blocks = blocks)

flacco documentation built on April 1, 2020, 1:06 a.m.