[R-sig-Geo] Automatically count independent group of points

Guillaume Blanchet gblanchet.list at gmail.com
Tue Aug 3 22:57:11 CEST 2010


  Hi !

I am currently working on a wombling (boundary detection) function and I 
have come across a nag. Hopefully you will be able to give me a hand on 
this.

Following is a small example to explain what I want to do using the 
spdep package.

xy<-expand.grid(1:4,1:2)
nbobj<-cell2nb(4,2,"rook")

links<-listw2sn(nb2listw(nbobj))
links.new<-links[-c(4,6,15,17),]

nbobj.new<-sn2listw(links.new)$neighbours

plot(nbobj.new,xy)

"nbobj.new" has two separate groups of points links between each other. 
Is there a way to automatically counts the number of independent 
(non-linked) groups of sites ?

Thanks in advance !

Guillaume Blanchet



More information about the R-sig-Geo mailing list