Dear list members, I want to plot a neighbours list of class nb. I thought that the plot would show 8 neighbour lines. But this is not the case for my plot. Did I do something wrong? col.knn2nb<-knn2nb(knearneigh(coords, k=8, longlat=F)) plot(coords, border="grey") plot(col.knn2nb, coords, xlim=NULL, ylim=NULL, add=TRUE) Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100824/d6e3902c/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: knn.jpeg Type: image/jpeg Size: 28959 bytes Desc: knn.jpeg URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100824/d6e3902c/attachment.jpeg>
knn2nb
3 messages · Sabira el Messlaki, Roger Bivand
On Tue, 24 Aug 2010, Sabira el Messlaki wrote:
Dear list members, I want to plot a neighbours list of class nb. I thought that the plot would show 8 neighbour lines. But this is not the case for my plot. Did I do something wrong? col.knn2nb<-knn2nb(knearneigh(coords, k=8, longlat=F)) plot(coords, border="grey") plot(col.knn2nb, coords, xlim=NULL, ylim=NULL, add=TRUE)
But: table(card(col.knn2nb)) table(sapply(col.knn2nb, anyDuplicated)) table(sapply(1:length(col.knn2nb), function(i) i %in% col.knn2nb[i])) show that each has eight unique neighbours, and that there are no self-neighbours. So perhaps neighbours in the same direction have lines that superimpose? Roger
Thanks in advance
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100825/0a2df74d/attachment.pl>