如何从纬度和经度获取最近的重要人口中心?

发布于 2024-08-09 04:58:13 字数 213 浏览 16 评论 0原文

我目前正在尝试使用虚拟地球/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

止于盛夏 2024-08-16 04:58:13

我认为可以安全地假设最近的城市与地球的大小相比总是非常接近,因此您可以使用简单的毕达哥拉斯三角形。

假设您位于 (lat0, long0),而试验城市位于 (lat1, long1)。

水平 (EW) 距离大致

d_ew = (long1 - long0) * cos(lat0)

为 乘以 cos(lat0),以考虑到经线在高纬度地区变得更加靠近。

垂直(NS)距离更容易

d_ns = (lat1 - lat0)

因此两点之间的距离为

d = sqrt(d_ew * d_ew + d_ns * d_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

d_ew = (long1 - long0) * cos(lat0)

This is multiplied by cos(lat0) to account for longitude lines getting closer together at high latitude.

Vertical (NS) distance is easier

d_ns = (lat1 - lat0)

So the distance between the two points is

d = sqrt(d_ew * d_ew + d_ns * d_ns)

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.

小清晰的声音 2024-08-16 04:58:13

尝试使用维基百科定位服务,记录在此处
http://www.geonames.org/export/wikipedia-webservice.html

try using the wikipedia location service, documented here
http://www.geonames.org/export/wikipedia-webservice.html

迷荒 2024-08-16 04:58:13

听起来您正在寻找主要城市的纬度和经度数据库,以便您可以计算距离。

是一个指向全球几十个页面的链接。

可能还有其他的,很可能以美国为中心(但这可能就是您想要的)。

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).

ら栖息 2024-08-16 04:58:13

我将执行以下操作:

表 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文