fork download
  1. from math import radians, degrees, sin, cos, asin, acos, sqrt
  2. R = 6378.137 #km
  3. def great_circle(lon1, lat1, lon2, lat2):
  4. lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
  5. return R * (
  6. acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2))
  7. )
  8.  
  9. d = great_circle(139.74477,35.6544 ,
  10. 39.8261, 21.4225 )
  11. print( f'{d:,.2f} km')
  12.  
Success #stdin #stdout 0.02s 9468KB
stdin
Standard input is empty
stdout
9,491.28 km