Description Usage Arguments Details Value Author(s) Examples
A fast function to get neighbor indices.
1 |
i |
Source pixel ID number. |
n |
Number of neighbors to get. For a 3x3 neighborhood, this value is set to 1 (a single neighbor to each of the eight sides of the pixel). |
nrow |
The number of rows in the raster. |
ncol |
The number of columns in the raster. |
This is a fast function to get the indices of the neighbors to a pixel. It does not require the matrix/raster object, only the number of rows and columns, to find the neighbors. It returns the sorted indices for the pixel, including the focal pixel. If at the edge, it returns NAs so the length is always the number of neighbors asked.
A vector with integer indices.
Pedro Tarroso
1 2 | # the 3x3 neighbors of pixel 34, on a matrix with 200 rows and columns
ineigh(34, 1, 200, 200)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.