The Distance using Haversine Formula

Over the last weekend, there’s a simple question running on my head:

“How can I compute the distance between two points on the earth?”

I’ve already knew, since in the university, how to compute the distance between two points in the plane. But I was wondering whether the formula was also work for the non-plane ellipsoidal shape like earth. So I’ve done a little search on the Internet and I found that the formula was a little bit different.

I’ve come across this great-circle distance and Haversine formula. Never heard about them before but the basic of the both, which is called trigonometry, was once familiar. So I did a little reading on these subjects (but I’m not going to proof the formula; hello, mathematicians *smile*) and figured out how I can make a better use of it.

To make everything simple, I’ve used Google Geocode API to translate addresses to latitude and longitude points which means to get the correct result, you should always use the full address (along with the country) when possible.

To see the full codes, please check my github.

Also read...


  1. Pingback: Happy New Year | Ksetyadi's [B]Log

Leave a Reply

Your email address will not be published. Required fields are marked *