Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for calculating deviation with respect to the best fit line #8

Open
nzec opened this issue Jan 5, 2021 · 3 comments
Open
Labels
cli Alters command line interface enhancement New feature or request

Comments

@nzec
Copy link

nzec commented Jan 5, 2021

For reference: https://en.wikipedia.org/wiki/Simple_linear_regression

@burrscurr burrscurr added cli Alters command line interface enhancement New feature or request labels Jan 5, 2021
@burrscurr
Copy link
Owner

I think this is a great idea! Fitting the line with linear regression should result in an optimal squared deviation average, which IMHO should be a good straight line quality measure in general.

There are some aspects that need to be considered for implementation:

  1. linesman currently just calculates quality measures and fitting a line is somewhat a different thing. Creating a subcommand linesman fit distinct from to the default (measuring) linesman could be an option to avoid cluttering the command line interface.
  2. Interaction with spherical calculation: The straight line should be calculated in a sphere rather than with lon/lat coordinates (see Use spherical geometry #5). However, straight lines in a lon/lat coordinate system are not the shortest path on a sphere (like the earth) and vice-versa. Therefore, the simplest approach just fitting a linear function through the lat/lon points does not yield a correct solution in sphere. Though I think that this problem can be solved with a linear regression or some sort of ordinary least squares method, I'm not sure whether it is trivial. Do you have an idea on how to approach this?
  3. Sections with slower progress aka more points should not be more important in fitting than sections with less points. Therefore, it makes sense to use the gps track to interpolate the real movement and evaluate it compared to equidistant points on the straight line (see Interpolate/Resample the gpx track #4). Though I think that both features can be tackled separately, the interpolation-feature should be kept in mind when planning the implementation of the best-fit feature.

@nzec
Copy link
Author

nzec commented Jan 6, 2021

Methods to do this directly on the sphere are described here:

This would be the most accurate thing to do but would be very hard.

@burrscurr
Copy link
Owner

Ok, this might be doable, but its indeed very complicated.

In general, I think that linesman should prefer the gedoesic interpretation of "straight" line to the lat-lon-2d interpretation, as it makes more sense for long "straight" lines. On the other hand, mayhaps its common for gps trackers to not use a geodesic when determining the direct connection of two points – which would mean that implementing a geodesic regression wouldn't be of much practical use. Maybe input from user number 1 (geowizard) could help prioritizing this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Alters command line interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants