如何从纬度和经度获取最近的重要人口中心?
我目前正在尝试使用虚拟地球/Bing 地图网络服务对一系列纬度/经度坐标进行反向地理编码。虽然我可以成功检索该职位的地址,但我还需要能够检索该职位最近的重要人口中心,以便我可以显示到最近的城镇/城市/大都市等中心的标题和距离。这是为了位置在位置之间行驶的情况,例如在高速公路/高速公路上。
有没有人有任何想法如何做到这一点,因为我已经用头撞了几天了,但我一无所获!
提前干杯...
I'm currently trying to reverse geocode a series of lat/long co-ordinates using the Virtual Earth/Bing Maps web services. Whilst I can successfully retrieve an address for the positions I also need to be able to retrieve the closest significant population centre for the position so I can display a heading and distance to the centre of the nearest town/city/metropolis etc. This is for cases where the location is travelling between locations e.g. on a highway/motorway.
Has anyone out there got any ideas how to do this as I've been banging my head against it for a few days now and I've gotten nowhere!
Cheers in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为可以安全地假设最近的城市与地球的大小相比总是非常接近,因此您可以使用简单的毕达哥拉斯三角形。
假设您位于 (lat0, long0),而试验城市位于 (lat1, long1)。
水平 (EW) 距离大致
为 乘以 cos(lat0),以考虑到经线在高纬度地区变得更加靠近。
垂直(NS)距离更容易
因此两点之间的距离为
您可以改进此方法以完成更严格的任务,但这对于最近的城市来说应该足够了。
为了比较距离,比较 d 平方就可以了,这意味着您可以省略 sqrt 运算。
I think it is safe to assume that the nearest city is always quite close compared with the size of the Earth, so you can use a simple pythagoras triangle.
Suppose you are at (lat0, long0) and a trial city is at (lat1, long1).
Horizontal (EW) distance is roughly
This is multiplied by cos(lat0) to account for longitude lines getting closer together at high latitude.
Vertical (NS) distance is easier
So the distance between the two points is
You can refine this method for more exacting tasks, but this should be good enough for the nearest city.
For comparing distances, it will be fine to compare d squared, which means you can omit the sqrt operation.
尝试使用维基百科定位服务,记录在此处
http://www.geonames.org/export/wikipedia-webservice.html
try using the wikipedia location service, documented here
http://www.geonames.org/export/wikipedia-webservice.html
听起来您正在寻找主要城市的纬度和经度数据库,以便您可以计算距离。
此是一个指向全球几十个页面的链接。
可能还有其他的,很可能以美国为中心(但这可能就是您想要的)。
It sounds like you're looking for a database of latitudes and longitudes of major cities, so you can calculate distances.
This is a link to a page giving a few dozen, world-wide.
There may be others, most likely US-centric (but that may be what you want).
我将执行以下操作:
表 1:
T_CityPopulation
字段:
CityTownInfo、Population、LonLat
然后计算表 1 中每条记录的当前 LonLat 之间的距离,使用阈值忽略超过 x 英里的城镇/城市。然后按人口对结果进行排序。
编辑:
即使您不想维护表,它也必须存储在某个地方,我认为如果您自己维护它,至少您可以控制它,而不是依赖其他服务。
I would do the following:
table 1:
T_CityPopulation
Fields:
CityTownInfo,Population,LonLat
Then compute distance between your current LonLat for each record in table 1, using a threshold value ignore towns/citys over x miles. Then sort the results by Population.
EDIT:
Even if you don't want to maintain a table, it has to be stored somewhere, I think if you maintained it yourself at least you have control over it, vs relying on another service.