rneigh: Get neighbor indices of a raster

Description Usage Arguments Details Value Author(s) Examples

View source: R/gol.R

Description

A wrapper for ineigh to get raster neighbor indices.

Usage

1
rneigh(i, raster, neigh=1, rm.focal=T)

Arguments

i

Source pixel ID number.

raster

The raster object to extract row and column numbers.

neigh

The number of neighbors to get.

rm.focal

Remove the focal pixel from the results?

Details

This is a wrapper for ineigh that simplifies getting the neighbors of a pixel in a raster object.

Value

A vector with integer indices.

Author(s)

Pedro Tarroso

Examples

1
2
3
4
	# the 3x3 neighbors of pixel 34, on a raster with 360 columns and 180 rows.
	require(raster)
	rst <- raster(nrow=180, ncol=360)
	rneigh(34, rst)

ptarroso/gameR documentation built on Nov. 17, 2021, 12:33 a.m.