from math import radians, degrees, sin, cos, asin, acos, sqrt
R = 6378.137 #km
def great_circle(lon1, lat1, lon2, lat2):
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
return R * (
acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2))
)
d = great_circle(139.74477,35.6544 ,
39.8261, 21.4225 )
print( f'{d:,.2f} km')
ZnJvbSBtYXRoIGltcG9ydCByYWRpYW5zLCBkZWdyZWVzLCBzaW4sIGNvcywgYXNpbiwgYWNvcywgc3FydApSID0gNjM3OC4xMzcgI2ttCmRlZiBncmVhdF9jaXJjbGUobG9uMSwgbGF0MSwgbG9uMiwgbGF0Mik6CiAgICBsb24xLCBsYXQxLCBsb24yLCBsYXQyID0gbWFwKHJhZGlhbnMsIFtsb24xLCBsYXQxLCBsb24yLCBsYXQyXSkKICAgIHJldHVybiBSICogKAogICAgICAgIGFjb3Moc2luKGxhdDEpICogc2luKGxhdDIpICsgY29zKGxhdDEpICogY29zKGxhdDIpICogY29zKGxvbjEgLSBsb24yKSkKICAgICkKCmQgPSBncmVhdF9jaXJjbGUoMTM5Ljc0NDc3LDM1LjY1NDQgLAogMzkuODI2MSwgMjEuNDIyNSApCnByaW50KCBmJ3tkOiwuMmZ9IGttJykK