ngb8 | R Documentation |

Return the 8 neighbors, as cell numbers, of each cell on a raster.

ngb8(n_row, n_col)

`n_row` |
Integer. The number of rows of a Raster or object. |

`n_col` |
Integer. The number of columns of a Raster object. |

A cell with coordinates `(x, y)`

has 8 neighbors with
coordinates: `(x±1, y)`

, `(x, y±1)`

and `(x±1, y±1)`

. Cells
on the edge of a raster have less than 8 neighbors. The function identifies
the neighbors of a cell as cell numbers.

Named list, the `nth`

element of the list corresponds to the 8
adjacent cell numbers of the `nth`

cell on the `Raster*`

object.

`ngbList()`

## Matrix m mocking a raster of 3 rows and 4 columns m <- matrix(1:12, nrow = 3, ncol = 4, byrow = TRUE) m nbs <- ngb8(3, 4) nbs

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.