[R-sig-Geo] Done!: Simultaneous interactive plot of hc dendrogram and geographic display
Agustin Lobo
Agustin.Lobo at ija.csic.es
Tue Oct 30 13:16:44 CET 2007
Well, thanks to the many inputs I've got, I've been able of
displaying a hc tree on one graphic display and, through the
use of identify.hc() click a branch and get the involved polygons
geographically displayed on another graphic window. It is inspired on
the barplot example in the help page for identify.hc.
The normal situation would be clustering in the data slot
of the SpatialPolygonsDataFrame object. Here I'm using
a different table because I did not have the sps composition
for all the transects (polygons).
In the example below, ferns is a transects x sps data frame, where
the transects are some of the polygons in pols.
ferns.raup <- vegdist(ferns,method="raup")
ferns.hc <- hclust(ferns.raup)
plot(ferns.hc)
get(getOption("device"))()
nD <- dev.cur()
image(t1pc1s)
plot(boundary,lwd=2,col=2,add=T)
dev.set(dev.prev())
identify(ferns.hc, MAXCLUST=17, FUN=function(k) {color=readline("Enter
color: ");
plot(polysubset(polys=pols,tabla=ferns,posic=k),add=T,lwd=3,border=color,col=color)},
DEV.FUN = nD)
The involved function is:
"polysubset"
<-function(polys=pols,tabla=ferns,pos.nom="fern.class",posics=k)
{
tabla <- tabla[posics,]
sel <- match(names(tabla[,pos.nom]),polys at data$Site)
polys[sel,]
}
Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster
More information about the R-sig-Geo
mailing list