knn2nb

0th

Percentile

Neighbours list from knn object

The function converts a knn object returned by knearneigh into a neighbours list of class nb with a list of integer vectors containing neighbour region number ids.

Keywords
spatial
Usage
knn2nb(knn, row.names = NULL, sym = FALSE)
Arguments
knn
A knn object returned by knearneigh
row.names
character vector of region ids to be added to the neighbours list as attribute region.id, default seq(1, nrow(x))
sym
force the output neighbours list to symmetry
Value

The function returns an object of class nb with a list of integer vectors containing neighbour region number ids. See card for details of “nb” objects.

See Also

knearneigh, card

Aliases
  • knn2nb
Examples
example(columbus)
coords <- coordinates(columbus)
col.knn <- knearneigh(coords, k=4)
plot(columbus, border="grey")
plot(knn2nb(col.knn), coords, add=TRUE)
title(main="K nearest neighbours, k = 4")
Documentation reproduced from package spdep, version 0.6-9, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.