I am continuing to work with GPS data related to trail routes and am trying to optimize the code by removing route points from a GPX file that are very close to each other by setting the accuracy of the data coming in. I have found a weird quirk where
SetPrecision results in duplicates that can be removed, but
SetAccuracy does not.
This code brings in the data, plots the trail, removes duplicates, reveals how many route points there are, and the allows you to see how many decimal places the route points have been calculated to:
ClearAll[data]; ToExpression@Import["https://pastebin.com/raw/8KDcvMex", "String"]; trail = DeleteDuplicates[GeoPosition /@ data[[All, 1]]]; Length[trail] trail[] (*2031, 4 decimal places*)
[Note: There are 2128 points in the original dataset]
If I set the accuracy to drop it to 3 decimal places, you can see it reflects in the
GeoPosition but also returns the same number of points.
trailacc4 = DeleteDuplicates[SetAccuracy[GeoPosition /@ data[[All, 1]], 4]]; Length[trailacc4] trailacc4[] (*2031, 3 decimal places*)
Now, if I use
SetPrecision instead of
SetAccuracy I can get the same result in terms of decimal places, but it actually removes duplicates.
trailpre5 = DeleteDuplicates[SetPrecision[GeoPosition /@ data[[All, 1]], 5]]; Length[trailpre5] trailpre5[] (*746, 3 decimal places*)
SetPrecision every adjustment I make to the level of precision increases the number of duplicates as one would expect (precision of 4 gives two decimal places and 114 remaining route points). However, no matter what level of accuracy I set with
SetAccuracy I get the same result -- 2031 remaining route points. The
GeoPosition shows with fewer decimal points, but nothing is being removed.
Is this a bug, or do
SetPrecision somehow work fundamentally differently with
With GPS data the difference between Accuracy and Precision makes a difference because you can have either 1, 2, or 3 figures to the left of the decimal.
I have tried setting the accuracy and precision directly to the data before GeoPositioning it, but every combination return 2037 resulting route points.