1

I have some GPS coordinates series taken in regular time steps and I need to verify whether some chunks of the trajectories fit well as a straight line or not. The aim is to perform segmentation on each trajectory, I am already able to find hard curves quite well, but the other segments are straight lines and smooth curves, I'd like to separate them based on a criterion of goodness of fit to a straight line.

The whole trajectories are not so big (usually not much bigger than 50 miles or kilometres) so spherical geometry corrections and haversine distances are not really required for this, but they would be interesting if simple.

I thought about fitting an $Y=aX+b$ model (longitude $X$, latitude $Y$) and looking at the $r^2$, but if a trajectory is nearly south to north I could have different results than the same trajectory rotated by 90 degrees since the values of $a$ and $b$ would be quite unstable.

Linearly fitting each coordinate versus time, hoping that if both fits well then I'd have a good fit may solve this issue, but I don't know if this is a valid approach nor if $r^2$ would be the best measure neither how to combine those $r_x^2$ and $r_y^2$.

Does anyone know a more appropriate way of verifying the goodness of fit of a straight line in such GPS series?

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
rafa
  • 153
  • 1
  • 1
  • 5
  • So you know the chunks of points you want to test for straightness ahead of time? If that is the case, you might want to examine [principal components analysis](http://stats.stackexchange.com/a/2700/1036) as opposed to regression. – Andy W Jun 12 '14 at 12:47
  • @AndyW I think this may be a good option. However, for measuring a score of goodness, do you think that the second eigenvalue would be good for this? I mean, if it is a straight line, then it would be much smaller than the first eigenvalue, or in the same order of the noise. – rafa Jun 12 '14 at 13:39
  • A similar measure to r^2 in regression would be the first eigenvalue divided by the sum of the two eigenvalues (make sure to detrend the mean of each x and y values, but here you can use the covariances for the PCA). IMO though I would just calculate the deviations from the line (e.g. absolute error of the distance) and use these to determine if they are a reasonable fit. I would think you have a personal idea about what is a reasonable amount of wiggle around a straight line give your application. – Andy W Jun 12 '14 at 17:56
  • 1
    @AndyW Well, in the end, not only the ratio between second and first eigenvalues worked well, but also the absolute value of the second eigenvalue was quite helpful since it gave me the greatness of the error perpendicular to the direction of the line in meters :) – rafa Jul 21 '14 at 13:23

0 Answers0