Skip to content

knn2nb

3 messages · Sabira el Messlaki, Roger Bivand

#
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>
#
On Tue, 24 Aug 2010, Sabira el Messlaki wrote:

            
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