[R-sig-Geo] eculidean threshold for clustering

Roger Bivand Roger.Bivand at nhh.no
Tue Oct 26 13:05:06 CEST 2010


On Tue, 26 Oct 2010, jgarcia at ija.csic.es wrote:

> Dear all,
> I am wondering if there is a direct function (I cannot find any) in R, to
> obtain, a "factor" vector to identify which points could be grouped in a
> set, using a specific threshold distance as clustering criterion.
>
> #e.g, with 7 points with coordinates:
>
> x <- c(1.01,0.95,1.05,1.03,3.03,2.99,3.04)
> y <- c(3.01,3.02,3.04,5.23,2.01,2.02,1.98)

library(spdep)
dnb <- dnearneigh(cbind(x, y), 0, 0.5)
n.comp.nb(dnb)$comp.id
# [1] 1 1 1 2 3 3 3

>
> # and, let's say, distance threshold 0.5, the answer would be:
> (1,1,1,2,3,3,3)
>
> # where the threshold is the maximum distance between any two points for
> each cluster
>
> A better approach would be that threshold could be specified as the
> distance between any point in each cluster, and its corresponding center
> of mass for that cluster, but I guess this would require some loops. Isn't
> it? S, I would be happy enough with the abovementioned approach.

I think that this might need hierarchical clustering and custom cut-offs 
and # clusters.

Hope this helps,

Roger

>
> If there isn't a direct function, don't worry. I'll try to find a solution
> computing distances...
>
> Thanks,
> Javier
> ---
>
>
>
>
>> is it possible to load a complete Grass mapset into a raster stack or
>> brick
>> with a single command?
>>
>> --
>> View this message in context:
>> http://r-sig-geo.2731867.n2.nabble.com/Grass-and-raster-package-tp5667199p5667199.html
>> Sent from the R-sig-geo mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
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



More information about the R-sig-Geo mailing list