Hello,

Here is a possibility:

library(maptools)
XY <- cbind(X=c(100,102,104,102,103),Y=c(12,14,14,13,16))
dst <- spDists(XY[1:4,],XY[2:5,],longlat=TRUE)
?spDists

HTH,
Pascal

Le 18/12/2012 18:56, Johannes Radinger a écrit :
Hi,

I have a dataframe containing 3 columns:

data.frame(X=c(100,102,104,102,103),Y=c(12,14,14,13,16),Time=c(1,2,3,4,5))

where X and Y are coordinates and "Time" refers to an index of a timestep.
Now I would like to get the distance between the consecutive timesteps.

This should actually provide a vector of length=4, representing the euclidian
resp. geopgraphic distance between the first and the second, and the second
and the third timestep and so on...

Is there a simple way to calculate this and get the resulting vector
as a result?
Or can anyone give an example?


best regards,
/j

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to