data(columbus)
knn1 <- knearneigh(coords, 1)
knn2 <- knearneigh(coords, 2)
nb1 <- knn2nb(knn1, row.names=rownames(columbus))
nb2 <- knn2nb(knn2, row.names=rownames(columbus))
diffs <- diffnb(nb2, nb1)
plotpolys(polys, bbs, border="grey")
plot(nb1, coords, add=TRUE)
plot(diffs, coords, add=TRUE, col="red", lty=2)
title(main="Plot of first (black) and second (red)
nearest neighbours")
Run the code above in your browser using DataLab