Re: [R] Calculate geographic/euclidian distance between consecutive XY-pairs

2012-12-18 Thread Johannes Radinger
Hi Ray, thank you very much. That one-line approach is what I was looking for. A very simple but very efficient way without loading any other packages. /j On Tue, Dec 18, 2012 at 11:17 AM, Ray Brownrigg wrote: > On 18/12/2012 10:56 p.m., Johannes Radinger wrote: >> >> Hi, >> >> I have a datafra

Re: [R] Calculate geographic/euclidian distance between consecutive XY-pairs

2012-12-18 Thread Pascal Oettli
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,

Re: [R] Calculate geographic/euclidian distance between consecutive XY-pairs

2012-12-18 Thread Ray Brownrigg
On 18/12/2012 10:56 p.m., Johannes Radinger wrote: 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