Haversine
使用纬度和经度计算地球上两个点之间的距离(以各种单位表示)。
安装
$ pip install haversine
用法
计算里昂到巴黎的距离
from haversine import haversine , Unit
lyon = ( 45.7597 , 4.8422 ) # (lat, lon)
paris = ( 48.8567 , 2.3508 )
haversine ( lyon , paris )
>> 392.2172595594006 # in kilometers
haversine ( lyon , paris , unit = Unit . MILES )
>> 243.71201856934454 # in miles
# you can also use the string abbreviation for units:
haver
1