代码:

  1. from geopy.distance import vincenty
  2. from geopy.distance import great_circle
  3.  
  4. 天安门 = (39.90733345, 116.391244079988)
  5. 大连 = (38.9122, 121.602)
  6. print('大连到天安门的直线距离:',vincenty(天安门, 大连).kilometers,'公里')
  7. print('大连到天安门的球面距离:',great_circle(天安门, 大连).kilometers,'公里')

输出:

  1. C:\Users\horn1\Desktop\python\50-geopy>python distance.py
  2. 大连到天安门的直线距离: 462.09653279793 公里
  3. 大连到天安门的球面距离: 461.06321019174163 公里

参考资料:https://blog.csdn.net/Next_Second/article/details/78618081?locationNum=2&fps=1

2018年5月15日

【Python】用geopy查两经纬度间的距离的更多相关文章

  1. Python计算地图上两点经纬度间的距离

    处理地图数据时,经常需要用到两个地理位置间的距离.比如A点经纬度(110.0123, 23.32435),B点经纬度(129.1344,25.5465),求AB两点之间的距离.我们可以用haversi ...

  2. Java计算两个经纬度间的距离最简单的方式

    开发中经常会遇到计算两个点(经纬度)之间的距离或者计算最近门店的场景,下面简单实现一下如何计算两个经纬度之间相隔的距离. 1.导入geodesy的maven依赖 或者到阿里云maven仓库下载jar包 ...

  3. php计算经纬度间的距离

    <?php //根据经纬度计算距离 function getdistance($lng1,$lat1,$lng2,$lat2) { //将角度转为狐度 $radLat1=deg2rad($lat ...

  4. Js算两经纬度间球面距离

    function GetDistance( lat1, lng1, lat2, lng2){ var radLat1 = lat1 * Math.PI / 180.0 var radLat2 = la ...

  5. poj 3608 Bridge Across Islands 两凸包间最近距离

    /** 旋转卡壳,, **/ #include <iostream> #include <algorithm> #include <cmath> #include ...

  6. js计算两经纬度之间的距离

    js如下: // 方法定义 lat,lng function GetDistance( lat1, lng1, lat2, lng2){    var radLat1 = lat1*Math.PI / ...

  7. IOS 计算两个经纬度之间的距离

    IOS 计算两个经纬度之间的距离 一 丶 -(double)distanceBetweenOrderBy:(double) lat1 :(double) lat2 :(double) lng1 :(d ...

  8. LCA - 求任意两点间的距离

    There are n houses in the village and some bidirectional roads connecting them. Every day peole alwa ...

  9. C# JackLib系列之如何获取地球上两经纬度坐标点间的距离

    获取地球上两经纬度坐标点间的距离,利用[大圆距离公式]   A diagram illustrating great-circle distance (drawn in red) between tw ...

随机推荐

  1. STM32 USART 波特率计算

    The baud rate for the receiver and transmitter (Rx and Tx) are both set to the same value as program ...

  2. [Deepin 15] 编译安装 PHP-5.6.30

    先看下历史笔记: Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记 ################################# ...

  3. Ubuntu使用安装或者卸载软件!!!

    安装软件: 1.在应用商店里面下载安装 2.在终端sudo apt-get install 软件名 3.使用ppa:加入一个ppa源:sudo add-apt-repository ppa:user/ ...

  4. MongoDB入门必读(概念与实战并重)

    MongoDB入门必读(概念与实战并重) 一.概述 MongoDB是一个基于分布式文件存储的数据库开源项目.由C++语言编写.旨在为WEB应用提供可护展的高性能数据存储解决方案. MongoDB是一个 ...

  5. Bootstrap碎语

    这里记录下某段时间Bootstrap的零散碎片. 1.有关Bootstrap的参考网站: ● 官方:http://getbootstrap.com/● 主题:http://bootswatch.com ...

  6. linux 统计文件夹空间

     du -sh * | sort -nr 

  7. Pandas快速入门(一)

    快速使用 bogon:Documents rousseau$ ipython --pylab Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23 ...

  8. 数据库分库分表中间件:Mycat;分布式数据库;mysql的分布式事务

    官网:http://mycat.io/,里面有电子书籍可以下载:http://www.mycat.io/document/mycat-definitive-guide.pdf 旧版本下载地址:http ...

  9. MySQL 锁模式

    InnoDB implements standard row-level locking where there are two types of locks, shared (S) locks an ...

  10. Unicode和UTF-8之间的关系

    作者: 阮一峰 日期: 2007年10月28日 今天中午,我突然想搞清楚Unicode和UTF-8之间的关系,于是就开始在网上查资料. 结果,这个问题比我想象的复杂,从午饭后一直看到晚上9点,才算初步 ...