通过OSMNX从OpenStreetMap openstreetMap的城市中心坐标?

发布于 2025-01-23 08:32:11 字数 120 浏览 0 评论 0 原文

是否可以通过Python库OSMNX查询OpenStreetMap来检索城市的(LAT,长)坐标?该文档似乎建议可以访问属性数据,但我尚未看到检索城市中心坐标的途径。使用OSMNX地理编码器进行感兴趣的城市,导致了较差的结果。

Is it possible to query OpenStreetMap via the Python library OSMnx to retrieve the (lat,long) coordinates for a city? The documentation seems to suggest attribute data should be accessible but I've not yet seen a pathway to retrieving the coordinates of a city's center. Using the OSMnx geocoder for a city of interest led to a poor result.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

£烟消云散 2025-01-30 08:32:11

您可能想尝试与质心一起工作 - 显然不是口语定义中的市中心,但它为您带来了城市边界的中心:

gdf = ox.geocode_to_gdf('London').centroid
>>> POINT (-0.10942 51.50050

伦敦市中心将在...可以尝试“伦敦城市”,

gdf = ox.geocode_to_gdf('city of London')
>>> POINT (-0.09244 51.51441)

这为您提供了银行和圣保罗的位置... erm ...“特朗普街”,

而不是您在寻找的东西,我猜是出于各种原因,而是“中心”。

You may want to try to work with centroids - It's clearly not the city center in a colloquial definition, but it gives you the the center of the city boundaries:

gdf = ox.geocode_to_gdf('London').centroid
>>> POINT (-0.10942 51.50050

London's city center would be in ... erm ... Woolwich, but you can try "City of London"

gdf = ox.geocode_to_gdf('city of London')
>>> POINT (-0.09244 51.51441)

which gives you a location between Bank and St Paul's in... erm... "Trump Street"

Not what you are looking for I guess for various reasons, but it is the "center".

https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.centroid.html

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