[GRASS-user] Re: proximity mapping / site clustering

Dylan Beaudette dylan.beaudette at gmail.com
Fri Jul 21 18:43:29 EDT 2006


This sounds like a fun job for GRASS-R coupling!

sample case with the spearfish dataset and the vector 'bugsites'

#GRASS6.1
v.out.ascii bugsites > bugsites.xy 

start R:
-----------------------------------------------------------------
x <- read.table('bugsites.xy', sep="|")
names(x) <- c('easting', 'northing', 'cat')

y <- data.frame(x[,1:2])

library(cluster)

y.pam <- pam(y, 5)
plot(y, col=y.pam$clustering, main="Bugsites Spatial Clustering, 5 classes", 
cex=0.5, pch=16)

#the centroids of the clustering
points(y.pam$medoids, pch=15, col=1:5)

y$cluster <- y.pam$clustering
y$orig_cat <- as.numeric(row.names(y))

write.table(y, file='bugsites.clust', row.names=FALSE)
-----------------------------------------------------------------

#back in GRASS6.1
v.in.ascii in=bugsites.clust out=bclust fs=" " columns='x double, y double, 
cluster integer, orig_cat integer' skip=1

#display the clustered data with convex hulls:
d.rast elevation.10m

# there are 5 clusters
for x in `seq 1 5` 
do v.extract --o in=bclust where="cluster=$x" out=bclust_$x 
v.hull in=bclust_$x out=bclust_hull_$x; g.remove vect=bclust_$x
d.vect bclust_hull_$x
done

#display the clustered points
d.vect bclust icon=basic/box fcol=blue col=blue size=5

#note that in the attribute table there exists the original CAT and spatial 
cluster number:
 v.db.select bclust

cat|x|y|cluster|orig_cat
1|590232|4915039|1|1
2|590430|4915204|1|2
3|590529|4914625|1|3
4|590546|4915353|1|4
5|590612|4915320|1|5
6|590744|4915535|1|6


just for fun, here is a link to the image.
http://169.237.35.250/~dylan/temp/spatial_clustering_idea1.png


Cheers,

Dylan


On Friday 21 July 2006 14:33, M S wrote:
> followup/correction.
>
> The "hubbing" does not have to occur along the optimal route (steiner
> tree).  this is "line of sight" orientated (cell towers as example).
>
> On 7/21/06, M S <mseibel at gmail.com> wrote:
> >  So far the network engineer/planner (who happens to be my Dad) I have
> > been working with on using GRASS for WAN Network engineering and design
> > has been working out awesome.  After a successful steiner tree, i have
> > come to another problem to solve with GRASS.
> >
> > i have all these sites on the minimal connection network.  what i need to
> > do now on a simplistic level, is cluster the sites or aggregate them.
> > Clustering them by proximity is the first step, even though traffic
> > generation is another factor that will have to be added.
> >
> > I have looked at v.net.iso and v.net.alloc, but none seem to produce the
> > results sought after.  is there a function or combination of functions
> > that might cluster sites on the network based upon their proximity to
> > each other?
> >
> >
> > i used v.net.iso with roughly a mile iso band.  i was able to highlight
> > on the optimal network all sites within a mile of each other but those
> > were not the desired results.
> >
> > Any ideas?
> >
> > thanks in advance

-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341




More information about the grass-user mailing list