Description Usage Arguments Value Note Author(s) See Also Examples

The function builds a neighbours list for a grid topology. It works for a k-dimentional grid topology, k>=1.

1 2 |

`grid` |
An object of class |

`d` |
A scalar (for one dimentional grid) or a length k vector specyfying the number of grid cells in each direction of the k dimentions. |

`queen` |
Logical. Default is TRUE. To inform if the queen neighbourhood structure should be considered. If FALSE, only a hyper-cube with a common face will be considered neighbour. If TRUE, a single shared coordinate meets the contiguity condition. |

`nb` |
Default TRUE. If TRUE, return the result as a neighbours
list with class |

`self` |
Default FALSE, to indicate if the hyper-cube neighbour itself should be considered a neighbour. |

Either a matrix, if “nb” is FALSE or a neighbours list with
class `nb`

. See `card`

for details of “nb”
objects.

This applies to a k-dimentional grid topology.

Elias T Krainski eliaskrainski@gmail.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
nb <- grid2nb(d = c(5L, 5L, 5L))
nb
summary(nb)
gt <- GridTopology(c(.125,.1), c(.25,.2), c(4L, 5L))
nb1 <- grid2nb(gt, queen = FALSE)
nb2 <- grid2nb(gt)
sg <- SpatialGrid(gt)
plot(sg, lwd=3)
plot(nb1, coordinates(sg), add=TRUE, lty=2, col=2, lwd=2)
plot(nb2, coordinates(sg), add=TRUE, lty=3, col=4)
str(grid2nb(d=5))
``` |

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.