adjPairsMatrix: Adjacent-pairs matrix used by spread() hot loop

View source: R/RcppExports.R

adjPairsMatrixR Documentation

Adjacent-pairs matrix used by spread() hot loop

Description

Computes 4- or 8-direction neighbour pairs (from, to) for every input cell and filters out neighbours that fall off the raster top/bottom or wrap across left/right edges. Returns a 2-column integer matrix with column names "from" and "to". Equivalent to adj(..., pairs = TRUE) but without the data.table allocation/coercion overhead.

Usage

adjPairsMatrix(cells, numCol, numCell, directions)

Arguments

cells

integer vector of source cell indices (1-based)

numCol

integer; number of raster columns

numCell

integer; total number of raster cells

directions

integer; either 4 or 8

Value

A 2-column integer matrix with columns named from and to.


SpaDES.tools documentation built on Aug. 29, 2026, 1:07 a.m.