# tri2nb

0th

Percentile

##### Neighbours list from tri object

The function uses the 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.

Keywords
spatial
##### Usage
tri2nb(coords, row.names = NULL)
##### Arguments
coords
matrix of point coordinates with two columns
row.names
character vector of region ids to be added to the neighbours list as attribute region.id, default seq(1, nrow(x))
##### Details

If coordinates are duplicated, this function cannot be used. If the coordinates are from a grid, then they need to be ordered such that the first three are not collinear, so that the first triangle can be constructed. This can be achieved by randomising the order of the coordinates (possibly several times), and then re-ordering the order of the data to match the new order of the neighbour list - if this fix is used, remember to re-order the row.names argument as well as the coordinates! Please also note that triangulation of grid points will give arbitrary diagonal neighbours, which may not be a sensible outcome, and dnearneigh() may serve better where tri2nb() cannot be used.

##### Value

The function returns an object of class nb with a list of integer vectors containing neighbour region number ids.

knn2nb, dnearneigh, cell2nb

• tri2nb
##### Examples
example(columbus)
coords <- coordinates(columbus)
ind <- sapply(slot(columbus, "polygons"), function(x) slot(x, "ID"))
col.tri.nb <- tri2nb(coords, row.names=ind)
W <- as(nb2listw(col.tri.nb, style="B"), "CsparseMatrix")
plot(columbus, border="grey")
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,])

Documentation reproduced from package spdep, version 0.6-9, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.