简体   繁体   English

寻找英国邮政编码之间的距离

[英]Finding distances between UK postcodes

I am doing a project and am having trouble, I would like to know if there is a way to find the distance between two postcodes in python, to the nearest mile. 我正在做一个项目,遇到了麻烦,我想知道是否有办法找到python中两个邮政编码之间的距离,最接近的距离。 I have searched for ages and haven't stumbled across a solution I would like it if either someone could point me in the right direction. 我已经寻找了很多年头,也没有偶然发现一个我想要的解决方案,如果有人可以向我指出正确的方向。

I would like it so that when I put two postcodes into python it will output how far they are in miles from each other. 我希望这样,当我将两个邮政编码放入python时,它将输出它们彼此之间相距多远的距离。 I have tried to implement a map to show the distances in tkinter but this proved to me massively difficult so I have had to refrain from doing this and had to just make it show the distance 我试图实现一个地图来显示tkinter的距离,但是这在我看来非常困难,因此我不得不避免这样做,而只能使其显示距离

https://postcodes.io/ - service for getting various postcode info. https://postcodes.io/-用于获取各种邮政编码信息的服务。 You can use existing instance or you can spin up your own, it's free. 您可以使用现有实例,也可以自由使用自己的实例,它是免费的。

Service above gives you latitude and longitude for the specified postcode. 上面的服务为您提供了指定邮政编码的纬度和经度。 Having two postcodes gives you two points and their lat and long. 有两个邮政编码可以给您两点,以及它们的经度和纬度。

Having coordinates of two points makes it possible to define distance between these points. 具有两个点的坐标可以定义这些点之间的距离。 ( be aware that this formula ignores obstacles between points eg mountains. ) (请注意,此公式忽略了点之间的障碍,例如山脉。)

distance by coordinates - here is the formula. 坐标距离 -这是公式。

For more precise distance you can use google API. 要获得更精确的距离,您可以使用Google API。 It's not free. 它不是免费的。

API - google distance API. API-谷歌距离API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM