Resources and useful information
 
Calculate distance between two geographical coordinates
 

The formula to calculates distance between two points with geo-coordinates WGS84:
 

Dist = 6378 * ACOS(COS(LatA) * COS(LatB) * COS(LngB - LngA) + SIN(LatA) * SIN(LatB))


How to apply:

  1. The values of latitude and longitude must be provided in radians:  Value = Degrees * PI / 180
     
  2. 6378 is the diameter of earth in kilometers according to WGS84 system, to get the result in miles use a value of 3959.


Reference:

Data Definition
ACOS  Function that returns arccosine of a number (available in programming language or Excel)
COS Function that returns cosine of a number (available in programming language or Excel)
SIN Function that returns sine of a number (available in programming language or Excel)
PI Constant π (PI) with value of 3.141592654, built in function in SQL or programming language
LatA Latitude of point A, converted to radians: Degrees * PI / 180
LngA Longitude of point A converted in radian: Degrees * PI / 180
LatB Latitude of point B, converted to radians: Degrees * PI / 180
LngB Longitude of point B converted to radians: Degrees * PI / 180


Sample:

 

  Postal Code Locality Latitude Longitude
Point A 08003 Barcelona 41.3879169 2.16991870
Point B 28070 Madrid 40.4167413 -3.7032498
 

PI    =    3.141592654

LatA  =   41.3879169 * PI / 180
LngA  =    2.1699187 * PI / 180

LatB  =   40.4167413 * PI / 180
LngB  =   -3.7032498 * PI / 180

Dist = 6371 * ACos(Cos(LatA) * Cos(LatB) * Cos(LngB - LngA) + Sin(LatA) * Sin(LatB))

Distance between point A to point B:  505.17071 km