Hi all,
I followed the pathway of using R and its hierarchical clustering tools.
For all interested, I came up with following code that creates clusters
with a user-specified minimum distance between the cluster means.
So this code does not specify the number of clusters a priori.
x ← runif(100,0,150)
y ← runif(100,0,150)
df ← data.frame(x,y)
plot(df)
hc ← hclust(dist(df,method = “euclidean”), method=“average”)
plot(hc)
df$memb ← cutree(hc, h = 60)
cent ← NULL
for(k in 1:length(unique(df$memb))){
cent ← rbind(cent, colMeans(df[df$memb == k, , drop = FALSE]))
}
cent ← as.data.frame(cent)
summary(dist(cent))
plot(df$x,df$y,col=df$memb)
points(cent$x,cent$y,pch=15)
Of course this could also be used with a distance matrix provided
by any GRASS output (v.distance or distance along a network etc.)
Most probably there are also similar libraries for hierachical clustering
and cutting cluster dendrogramms available for python. Maybe together
with Pietro’s approach, its worth considering to write a short add-on, if this
is also of interest to other users.
Thanks for all your hints!
cheers,
Johannes
···
On Wed, Jul 9, 2014 at 6:11 PM, Pietro <peter.zamb@gmail.com> wrote:
Hi Johannes,
On Tue, Jul 8, 2014 at 1:58 PM, Johannes Radinger
<johannesradinger@gmail.com> wrote:
I’ve a point vector containing more than 500 points.
Some of these points are spatially clumped while
others are single independent points (from viewing the
map). Now I am wondering if there is any tool in
GRASS (or maybe other spatial-statistical software
like R) that can be used to group the data so that each
point clump is assigned to a group and each single group to its
own group. Of course, this needs a criterion where
to distinguish between groups/clusters. I’d like to have
groups that are separated by a distance of at least 5 km.
Is there any recommendation of a simple or more
advanced procedure to do that?
I play a bit with some machine learning algorithm, the code is:
https://gist.github.com/zarch/f849df450d622f9eadee
you can see the results apply to the vector map “points_of_interest”
present in the North Carolina mapset, here:
https://plus.google.com/115946523992149326262/posts/2R9HfQh6UvQ
cheers
Pietro