trackintel
trackintel copied to clipboard
BUG: `.centroid` does not wrap for angles
In #431 we discovered an error in calculating the mean angle for a location.
We calculate the average coordinates with .centroid
. This function assumes that the coordinate system is projected and therefor does not wrap around in a circle.
For example, if we compute the centroid of the multipoint [(0, 179), (0, -179)]
, we get the point (0, 0)
instead of the desired (0, 180)
.
This is equivalent to this problem (https://rosettacode.org/wiki/Averages/Mean_angle), for a geographical explanation see (https://carto.com/blog/center-of-points/).
A suggested solution would be to implement a new function in util.py
. You can also take a look at https://github.com/mie-lab/trackintel/blob/4f4868b6547bfceb05447e221bb681f8cd389fd7/trackintel/preprocessing/positionfixes.py#L455
That suffers from the same bug.