AgTalk Home
AgTalk Home
Search Forums | Classifieds (150) | Skins | Language
You are logged in as a guest. ( logon | register )

Measuring the distance between two points
View previous thread :: View next thread
   Forums List -> Precision TalkMessage format
 
mx270a
Posted 7/2/2017 21:28 (#6102431)
Subject: Measuring the distance between two points



Cedar Rapids, Iowa
I learned something this week related to measuring distance between two latitude/longitude points, and I thought I should share. There are some fellow programmers on here that may find this useful.

When I started working with GPS data, I needed a formula to calculate the distance between two points. I found a well-published formula called the 'great circle formula'. It's a lot of trigonometry. What I didn't realize is that this formula assumes the earth is a perfectly round sphere, which it isn't. The earth is a bit fatter at the equator than it is from pole-to-pole.

There is a better method called 'Vincenty's formula'. It is more complicated, a lot more code, but also more accurate. From what I've read, it takes about 2x the computing power, but since we're now working with processors that are in the GHz range, we don't care about the extra processor load.

The difference between these two formulas is somewhere around 0.1%. The way I found out about this was someone was using code I wrote to check a professional surveyor and found a difference of about 2 feet on a half mile. When investigating why there was a difference, this showed up.

The great circle formula is 9 lines of code. Vincenty's is 32 lines and contains a Do/While loop that could run up to 100 times. I genuinely have no idea how a mathematician figured out this stuff.
https://en.wikipedia.org/wiki/Vincenty%27s_formulae
Top of the page Bottom of the page


Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread

(Delete cookies)