计算地理坐标间的距离

目录

基础知识

示例代码

tips


​​​​​​​

计算经纬度间的距离
计算地理坐标间的距离
计算两个经纬度对间的距离
计算两个地理坐标间的距离
计算两点间的距离

基础知识

Geopy可以用 geodesic distance 或 great-circle distance ,默认测地线距离作为函数 geopy.distance.distance .

大圆距离( great_circle )使用地球的球形模型,使用国际大地测量学和地球物理学联合会定义的平均地球半径,(2)a + b) /3=6371.0087714150598公里,约6371.009公里(WGS-84),误差高达0.5%。半径值存储在 distance.EARTH_RADIUS ,因此可以对其进行自定义(但是,它应该始终以公里为单位)。

The geodesic distance is the shortest distance on the surface of an ellipsoidal model of the earth. The default algorithm uses the method is given by Karney (2013) (geodesic); this is accurate to round-off and always converges.

geopy.distance.distance 目前使用 geodesic .

有许多流行的椭球体模型,哪一个模型最精确取决于你的点在地球上的位置。默认值是WGS-84椭球体,它是全局最精确的。geopy还包括 distance.ELLIPSOIDS 字典:

              model             major (km)   minor (km)     flattening
ELLIPSOIDS = {'WGS-84':        (6378.137,    6356.7523142,  1 / 298.257223563),
              'GRS-80':        (6378.137,    6356.7523141,  1 / 298.257222101),
              'Airy (1830)':   (6377.563396, 6356.256909,   1 / 299.3249646),
              'Intl 1924':     (6378.388,    6356.911946,   1 / 297.0),
              'Clarke (1880)': (6378.249145, 6356.51486955, 1 / 293.465),
              'GRS-67':        (6378.1600,   6356.774719,   1 / 298.25),
              }

geopy文档简介
https://www.osgeo.cn/geopy/#module-geopy.distance

示例代码

使用geopy
代码

# 计算两点距离
from geopy.distance import geodesic
#25.102350,121.548432 # 台北故宫
#25.07639,121.22389 # 台北机场
apoint = (25.102350,121.548432) # 维度在前,经度在后
bpoint = (25.07639,121.22389)
print(geodesic(apoint, bpoint).km) # 默认使用GPS坐标系
print(geodesic(apoint, bpoint).m) # 默认使用GPS坐标系
apoint = (52.2322,21.0083) #华沙
bpoint = (52.5186,13.4081) #柏林
print(geodesic(apoint, bpoint).km)

tips

如何获取GPS信息:google华盛顿地理坐标

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

只要开始永远不晚

谢谢打赏~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值