[R-sig-Geo] Automatically count independent group of points
Nikhil Kaza
nikhil.list at gmail.com
Wed Aug 4 05:34:25 CEST 2010
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