用Python根据两点经纬度计算距离
2016-06-15 14:34
746 查看
def calcDistance(Lat_A, Lng_A, Lat_B, Lng_B): ra = 6378.140 rb = 6356.755 flatten = (ra - rb) / ra rad_lat_A = radians(Lat_A) rad_lng_A = radians(Lng_A) rad_lat_B = radians(Lat_B) rad_lng_B = radians(Lng_B) pA = atan(rb / ra * tan(rad_lat_A)) pB = atan(rb / ra * tan(rad_lat_B)) xx = acos(sin(pA) * sin(pB) + cos(pA) * cos(pB) * cos(rad_lng_A - rad_lng_B)) c1 = (sin(xx) - xx) * (sin(pA) + sin(pB)) ** 2 / cos(xx / 2) ** 2 c2 = (sin(xx) + xx) * (sin(pA) - sin(pB)) ** 2 / sin(xx / 2) ** 2 dr = flatten / 8 * (c1 - c2) distance = ra * (xx + dr) return distance
目前各个地图的经纬度坐标还是有差异的,为了开发人员能方便的进行坐标间的转化,顺带分享一个经纬度坐标转换的api,点击打开链接
还是很不错的,但是好像一天有几千次的限制,不太记得了,管他呢,能用就行。
相关文章推荐
- Android Manifest 用法
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 什么是 GraphQL?
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- Spark RDD API详解(一) Map和Reduce
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Spring Boot 开发微服务
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用