python 通过两个点的经纬度计算距离
发布时间:2020-12-17 17:00:18 所属栏目:Python 来源:网络整理
导读:谷歌map计算公式: python代码: def?haversine(lon1,?lat1,?lon2,?lat2):?#?经度1,纬度1,经度2,纬度2?(十进制度数)????"""????Calculate?the?great?circle?distance?between?two?points????on?the?earth?(specified?in?decimal?degrees)????"""????#?
谷歌map计算公式: python代码: def?haversine(lon1,?lat1,?lon2,?lat2):?#?经度1,纬度1,经度2,纬度2?(十进制度数) ????""" ????Calculate?the?great?circle?distance?between?two?points ????on?the?earth?(specified?in?decimal?degrees) ????""" ????#?将十进制度数转化为弧度 ????lon1,?lat2?=?map(radians,?[lon1,?lat2]) ???? ????#?haversine公式 ????dlon?=?lon2?-?lon1 ????dlat?=?lat2?-?lat1 ????a?=?sin(dlat/2)**2?+?cos(lat1)?*?cos(lat2)?*?sin(dlon/2)**2 ????c?=?2?*?asin(sqrt(a)) ????r?=?6371?#?地球平均半径,单位为公里 ????return?c?*?r?*?1000????#?输出值单位公里 参考文章: http://blog.csdn.net/vernice/article/details/46581361 经纬度距离计算小工具: http://www.storyday.com/wp-content/uploads/2008/09/latlung_dis.html 更多关于谷歌计算两点的文章: https://developers.google.com/s/results?q=computeDistanceBetween (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |