Knowledge Base Article

Calculate Distance Between Two Points Using Latitude and Longitude

In this post, we show the formula to calculate the shortest distance between two points using Latitude and Longitude.
This calculation can be useful when trying to determine the distance for logistical purposes (ie delivery service, flights, distance between customers, etc).
Example
The file will need to be set up using the following columns Start_place, Start_latitude, Start_longitude, End_place, End_Latitude, End_Longitude.  The calculation will need to be done in the ElastiCube using a custom field(s).  Replace the Lat_start, Lat_end, Long_start, and Long_end with the relevant fields.  
Note:
The radius of Earth in Miles is 3963 (part of the calculation)
The radius of Earth in Kilometers is 6378 (part of the calculation)
The Calculation in Miles:
ACOS(SIN(PI()*[Lat_start]/180.0)*SIN(PI()*[Lat_end]/180.0)+COS(PI()*[Lat_start]/180.0)*COS(PI()*[Lat_end]/180.0)*COS(PI()*[Long_start]/180.0-PI()*[Long_end]/180.0))*3963
The Calculation in Kilometers
ACOS(SIN(PI()*[Lat_start]/180.0)*SIN(PI()*[Lat_end]/180.0)+COS(PI()*[Lat_start]/180.0)*COS(PI()*[Lat_end]/180.0)*COS(PI()*[Long_start]/180.0-PI()*[Long_end]/180.0))*6378
Updated 03-02-2023
No CommentsBe the first to comment