deldir
package to convert a matrix of
two-dimensional coordinates into a neighbours list of class nb
with a list of integer vectors containing neighbour region number
ids.tri2nb(coords, row.names = NULL)
region.id
, default seq(1, nrow(x))
nb
with a list of integer vectors containing neighbour region number ids.dnearneigh()
may serve better where tri2nb()
cannot
be used.knn2nb
, dnearneigh
, cell2nb
example(columbus)
coords <- coordinates(columbus)
ind <- sapply(slot(columbus, "polygons"), function(x) slot(x, "ID"))
col.tri.nb <- tri2nb(coords, row.names=ind)
plot(columbus, border="grey")
plot(col.tri.nb, coords, add=TRUE)
title(main="Raw triangulation links")
x <- seq(0,1,0.1)
y <- seq(0,2,0.2)
xy <- expand.grid(x, y)
try(xy.nb <- tri2nb(xy))
seed <- 1234
xid <- sample(1:nrow(xy))
xy.nb <- tri2nb(xy[xid,])
plot(xy.nb, xy[xid,])
Run the code above in your browser using DataLab