Skip to content
Back to formatted view

Raw Message

Message-ID: <507AF669.5010408@yahoo.com.br>
Date: 2012-10-14T17:29:13Z
From: Cleber N.Borges
Subject: How to transform the paths of MST {ape} in SpatialLines objects {sp} ?

Hello all,

I would like to transform the paths of MST {ape}  in SpatialLines objects.
But I don't understand the mechanical procedure in SpatialLines-class of 
'sp' package.

Please, somebody can help me?

Thanks in advanced.
Cleber N.Borges


### my (half) trial
library(sp);
library(ape) # for 'mst' function

n <- 20
x <- runif( n )
y <- runif( n )
coords <- cbind( x, y )
plot( coords )

r <- which( mst(dist(coords))==1, arr.ind=T )

segments( coords[r[,1],1], coords[r[,1],2], coords[r[,2],1], 
coords[r[,2],2] )