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.
adjPairsMatrix(cells, numCol, numCell, directions)A 2-column integer matrix with columns named from and to.
integer vector of source cell indices (1-based)
integer; number of raster columns
integer; total number of raster cells
integer; either 4 or 8