Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gridindex2nb

create neighbourhood (nb) object from grid geometry


Description

create neighbourhood (nb) object from grid geometry

Usage

gridIndex2nb(obj, maxdist = sqrt(2), fullMat = TRUE, ...)

Arguments

obj

object of class SpatialGrid or SpatialPixels

maxdist

maximum distance to be considered (inclusive), expressed in number of grid cell (sqrt(2) results in queen neighbours)

fullMat

use dist to compute distances from grid (row/col) indices; FALSE avoids forming the full distance matrix, at a large performance cost

...

arguments passed on to dist

Value

Object of class nb, which is a list.

The nb object follows the convention of nb objects in package spdep; it is a list with each list element corresponding to a grid cell or pixel; the list element contains the indices of neighbours defined as cells less than maxdist away, measured in cell unit (N/S/E/W neighbour has distance 1).

Note

Unequal grid cell size is ignored; grid cell row/col indices are taken to be the coordinates from which distances are computed.

Author(s)

See Also

plot.nb in package spdep


sp

Classes and Methods for Spatial Data

v1.4-5
GPL (>= 2)
Authors
Edzer Pebesma [aut, cre], Roger Bivand [aut], Barry Rowlingson [ctb], Virgilio Gomez-Rubio [ctb], Robert Hijmans [ctb], Michael Sumner [ctb], Don MacQueen [ctb], Jim Lemon [ctb], Finn Lindgren [ctb], Josh O'Brien [ctb], Joseph O'Rourke [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.