Skip to content

Do you know if you can map a large minimum spanning tree in R?

2 messages · Wade, Fiona M, Roger Bivand

#
Thanks Mike.
My data has longitude and latitude coords and I used distAB {clim.pact}
then mst {ape} to calculate my minimum spanning tree.  The nodes are
telecoms sites from all over Australia.  My goal is to determine the
minimum cost of linking them via cabling, and I'm starting by
calculating the distance "as the crow flies", but will probably
eventually need to calculate the rectilinear distances also.
I am a very newbie user of R, but have had experience with other
stats/programming software such as SAS, however no longer have access to
SAS so I've turned to R.  I also have tried using MapInfo with the data
exported from R, but have found that not so intuitive to learn on the
fly.
Back to R - I'm using W2K, and have managed to graph the tree using
plot(mdist,graph="nsca") where mdist is the output matrix from my mst
command, however this is not terribly map-like, so I'm looking for a
better display that can be embedded in a document.
Any assistance gratefully received!
Fiona.
If you are not the intended recipient, any use of, interference with,
disclosure or copying of this material is unauthorised and prohibited.
If you have received this message in error, please notify me by reply
e-mail and then delete the message.
-----Original Message-----
From: Michael Sumner [mailto:mdsumner at utas.edu.au]
Sent: Thursday, 19 August 2004 10:18 AM
To: Briggs, Meredith M; r-help at stat.math.ethz.ch
Cc: Wade, Fiona M
Subject: Re: [R] Do you know if you can map a large minmum spanning tree
in R?
At 09:47 AM 8/19/2004, Briggs, Meredith M wrote:

            
(all
You can certainly "map" in R.  Depending on the coordinate system of
your 
data . . .
but, e.g. - if it's lat/lon - perhaps the easiest way is to install the 
"maps" package and you can add the continental outlines to an existing
plot:

## display nodes code here . . .
library(maps)
map('world',add=T,xlim=c(109,157),ylim=c(-47,-7))

There are plenty of other options, if you have your own map data (or
want 
to use another source).  Feel free to provide more detail about your 
current plotting methods and coordinate system.

Also, the package "mapdata" contains a high resolution continental
dataset 
-"worldHires"

Hope that helps, Mike.





###############################################

Michael Sumner - PhD. candidate
Maths and Physics (ACE CRC & IASOS) and Zoology (AWRU)
University of Tasmania
Private Bag 77, Hobart, Tas 7001, Australia
Phone: 6226 1752
#
then mst {ape} to calculate my minimum spanning tree.  The nodes are
telecoms sites from all over Australia.  My goal is to determine the
minimum cost of linking them via cabling, and I'm starting by
stats/programming software such as SAS, however no longer have access to
SAS so I've turned to R.  I also have tried using MapInfo with the data
exported from R, but have found that not so intuitive to learn on the
fly.
plot(mdist,graph="nsca") where mdist is the output matrix from my mst
command, however this is not terribly map-like, so I'm looking for a
better display that can be embedded in a document.
One possibility is to use the fact that mst() function returns a 0/1
matrix exactly like spatial weights matrices used in the spdep package:
The plot.nb() function then plots the graph by joining points defined as
neighbours, use the add=TRUE argument to overplot on a base map. The nb
object can also be manipulated a little, like subsetting, if that is any
use. The idea is to convert the 0/1 matrix to a list with vectors of
neighbours' IDs for each point, rather than store the whole matrix.
Contact me off-list if you need more details. (nbdists() retrieves the
distances on the graph too).
disclosure or copying of this material is unauthorised and prohibited.
If you have received this message in error, please notify me by reply
e-mail and then delete the message.
in R?
if you can map in R?
would be on the map.
"maps" package and you can add the continental outlines to an existing
plot:
current plotting methods and coordinate system.