Skip to main content
edited tags
Link
clarify code
Source Link
kickert
  • 1.9k
  • 8
  • 24

A couple notes on the code above. For some reason Remember that Mathematica returns GeoNearest[combined[[All, 1]], waypoint] as a single item list (henceso you will either need to call the use offirst item with [[1]] in the code)as I did below or use First@GeoNearest[combined[[All, 1]], waypoint]. Also, if I don't precalculate nearest and use the following code, Mathematica gets the right answer, but takes several minutes compared to near instant results:

A couple notes on the code above. For some reason Mathematica returns GeoNearest[combined[[All, 1]], waypoint] as a single item list (hence the use of [[1]] in the code). Also, if I don't precalculate nearest and use the following code, Mathematica gets the right answer, but takes several minutes compared to near instant results:

A couple notes on the code above. Remember that Mathematica returns GeoNearest[combined[[All, 1]], waypoint] as a single item list so you will either need to call the first item with [[1]] as I did below or use First@GeoNearest[combined[[All, 1]], waypoint]. Also, if I don't precalculate nearest and use the following code, Mathematica gets the right answer, but takes several minutes compared to near instant results:

Tweeted twitter.com/StackMma/status/1012358009832574976
typo correction
Source Link
kickert
  • 1.9k
  • 8
  • 24

The cleaned up route data can be here: https://pastebin.com/8KDcvMex and can be imported directly:

Using that I data I then used the following code to plot the trail:

Then I bring in the waypoint I want to find the location of:

In looking for possible solutions, I found this example on the Wolfram Community andand he does some cool stuff using Accumulate as a way of calculating overall distance. I could use that function combined with finding the nearest route point and have the answer, but that won't always work. You see, there are gaps in some of the GPX route coordinates where at times there is up to half a mile between coordinates. I have cases where waypoints are returning the same route point as closest because they really are the closest in the dataset, even though the waypoints themselves are separated by some distance. In cases like that, my distance calculations could be off by a pretty substantial bit.

The cleaned up route data can be here: https://pastebin.com/8KDcvMex

Using that I data I then used the following code to plot the trail:

Then I bring in the waypoint:

In looking for possible solutions, I found this example on the Wolfram Community and he does some cool stuff using Accumulate as a way of calculating overall distance. I could use that function combined with finding the nearest route point and have the answer, but that won't always work. You see, there are gaps in some of the GPX route coordinates where at times there is up to half a mile between coordinates. I have cases where waypoints are returning the same route point as closest because they really are the closest in the dataset, even though the waypoints themselves are separated by some distance. In cases like that, my distance calculations could be off by a pretty substantial bit.

The cleaned up route data can be here: https://pastebin.com/8KDcvMex and can be imported directly:

Using that data I then used the following code to plot the trail:

Then I bring in the waypoint I want to find the location of:

In looking for possible solutions, I found this example on the Wolfram Community and he does some cool stuff using Accumulate as a way of calculating overall distance. I could use that function combined with finding the nearest route point and have the answer, but that won't always work. You see, there are gaps in some of the GPX route coordinates where at times there is up to half a mile between coordinates. I have cases where waypoints are returning the same route point as closest because they really are the closest in the dataset, even though the waypoints themselves are separated by some distance. In cases like that, my distance calculations could be off by a pretty substantial bit.

Updated to reflect new attempts
Source Link
kickert
  • 1.9k
  • 8
  • 24
Loading
Corrected last code line to call correct variable
Source Link
kickert
  • 1.9k
  • 8
  • 24
Loading
added 102 characters in body
Source Link
rhermans
  • 37.4k
  • 4
  • 61
  • 152
Loading
added 98 characters in body
Source Link
kickert
  • 1.9k
  • 8
  • 24
Loading
Formatted inline code
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198
Loading
Source Link
kickert
  • 1.9k
  • 8
  • 24
Loading