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.
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.
Returns
[list of integer(3)].
List of neighbours. Each list element stands for a combination of predecessing, current and succeeding cell.
Examples
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)