great_circle_distance

typhon.geodesy.great_circle_distance(lat1, lon1, lat2, lon2, r=None)[source]

Calculate the distance between two geographical positions

This is the ‘As-the-crow-flies’ distance between two points, specified by their latitude and longitude. This uses the so-called haversine formula, defined by:

\[d = 2 \arcsin \left( \sqrt{ \sin \left(\frac{\varphi_2-\varphi_1}{2} \right)^2 + \cos(\varphi_1) \cdot \cos(\varphi_1) \cdot \sin \left(\frac{\lambda_2-\lambda_1}{2} \right)^2} \right)\]
Parameters:
  • lat1 – Latitude of position 1.

  • lon1 – Longitude of position 1.

  • lat2 – Latitude of position 2.

  • lon2 – Longitude of position 2.

  • r (float) – The radius (common for both points).

Returns:

If the optional argument r is given, the distance in m is returned. Otherwise the angular distance in degrees is returned.