Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ledoan90
New Contributor

Calculate distance using Latitude and Longtitude with Google Map

Hi All,

I want to calculate the distance 2 points using latitude and longitude, i used the Haversine formula to calculate it but when i compare the result with Google Map km,  the result isn't same, please tell me, how can i convert the result of Haversine to the result of Google Map km.

Haversine formula:

( 2 *

(atan2(

sqrt((sqr(sin(((Latitude_etabli * Pi() / 180) - (latitude_ville * Pi() / 180)) / 2))

+ ((cos((latitude_ville * Pi() / 180)) * cos((Latitude_etabli * Pi() / 180)))

* sqr(sin(((Longitude_etabli * Pi() / 180) - (longitude_ville * Pi() / 180)) / 2))

)

)),

sqrt((1-(

sqr(sin(((Latitude_etabli * Pi() / 180) - (latitude_ville * Pi() / 180)) / 2))

+ ((cos((latitude_ville * Pi() / 180)) * cos((Latitude_etabli * Pi() / 180)))

* sqr(sin(((Longitude_etabli * Pi() / 180) - (longitude_ville * Pi() / 180)) / 2))

)

))

)))) * 6371 as Distance_km

Lat_1: 47.766667     Long_1: 2.8

Lat_2 : 47.085134     Long_2: 2.436788

Distance in Haversine formuma: 80,56 km

Distance in Google Map : 92.1 km

Thanks for yours help!