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

Dylan Beaudette dylan.beaudette at gmail.com
Sat Jul 22 19:16:25 EDT 2006


Be sure the read up on the documentation, as it is all spelled out there.

 A quick example of "partitioning around medoids", with known medoid
locations might be accomplished by combining the bugsites along with
user-digitized centers in R.

quick example:

#interactively digitize 3 "centers"
d.where | awk '{print $1"|"$2}' | v.in.ascii out=b_my_centers

#export as text:
v.out.ascii in=b_my_centers out=b_my_centers.xy

#switch to R
x <- read.table('bugsites.xy', sep="|")
y <- read.table('b_my_centers.xy', sep="|")

#name the columns in the imported dataframes
names(y) <- c('easting', 'northing', 'cat')
head(x)
names(x) <- c('cat','easting', 'northing', 'cost')
head(x)

#composite the two lists of points, keeping only the easting,northing
z <- rbind(x[,2:3], y[,1:2])
str(z)

#cluster around the medoids (the last three rows in z)
z.pam = pam(z, 3, stand=TRUE, medoids=c(91,92,93) )

#plot the results
plot(z$easting, z$northing, col=z.pam$clustering, main="Spatial Clustering aroun
d Medoids")
points(y$easting, y$northing, col=c(2,1,3), pch=16 )

output image here:
http://169.237.35.250/~dylan/temp/spatial_clustering_idea3-pam.png

filled circles are the medoids digitized in GRASS, hollow circles are
the original bugsites.
follow similar email on how to get this data back into GRASS.

note that a better way to do this would use the R/GRASS interface,
such that REAL spatial objects are moved between GRASS and R, instead
of just coordinates.


in regards to large datasets, pam() should work for perhaps 1,000
records, wheras clara() should be used for anything larger.

Cheers,

Dylan




On 7/22/06, M S <mseibel at gmail.com> wrote:
>
> fantastic.  for now some of this R and statistics is over my head!  i'll
> have to spend some time getting orientated.  thank you for the links.
>
> is this part below, referring to my previous question to cluster one mass of
> points around an other set of points that are much less? (eg, 50 points and
> how to cluster them around 3 points from another layer)
>
> clustering around set "medoids" with pam() or set "centroids" with
> kmeans() is fairly simple, just see the documents associated with
> these functions. the CRAN website will be a good start. also, for some
> rather generic R examples and documents see the link:
> http://casoilresource.lawr.ucdavis.edu/drupal/node/100
>
> I would love to post my steiner results.  maybe i can do the same thing on
> spearfish data because the data i used is client specific.  I'll make a run
> on the spearfish60 data, and provide a step by step walk through.




More information about the grass-user mailing list