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

Guillaume Blanchet gblanchet.list at gmail.com
Wed Aug 4 15:59:13 CEST 2010


  Thanks Nikhil !!

That is solving my problem !!

Have a good day !

Guillaume Blanchet

Le 10-08-03 21:34, Nikhil Kaza a écrit :
>
> This may be a overkill. but no.clusters in igraph package might work.
>
> require(igraph)
> nbobj <- cell2nb(4,2,"rook")
> nb.mat <- nb2mat(nbobj)
> no.clusters(graph.adjacency(nb.mat))
>
>
> Nikhil Kaza
> Asst. Professor,
> City and Regional Planning
> University of North Carolina
>
> nikhil.list at gmail.com
>
> On Aug 3, 2010, at 4:57 PM, Guillaume Blanchet wrote:
>
>> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>



More information about the R-sig-Geo mailing list