如何使用 OSMNX 检索 `route=bicycle` 类型的关系?

问题描述 投票:0回答:1

我想使用 OSMNX 包从 Open Street Map 中提取几条自行车游览路线。 例如,这条自行车路线具有属性

type=route
route=bicycle
。然而,由于它们是关系而不是方法,我无法使用 OSMNX Features 模块中的函数:

有其他方法来提取这些数据吗?

我使用功能模块的尝试:

import osmnx as ox
ox.__version__ # '1.5.1'

tags = {"route": "bicycle"}
gdfox = ox.features_from_place("Charente-Maritime", tags)
gdfox.shape  # (0,0)
python openstreetmap geopandas osmnx
1个回答
0
投票

有其他方法来提取这些数据吗?

是的。根据 OSMnx 文档

features
模块通过 OSM 标签搜索来查找匹配元素。您在这里寻找特定的关系,因此您应该使用
geocoder
模块来检索它们。根据文档,此模块允许您“按名称或 ID 检索地点边界或任何其他 OpenStreetMap 元素”。比如:

import osmnx as ox
ox.settings.log_console = True
ox.geocoder.geocode_to_gdf("R8695368", by_osmid=True)

但是,有一个警告:由于某种原因,您的示例关系在 Nominatim 本身中“缺失”。这种情况以前发生过(相关问题),如果缺少,可能值得您直接向 Github 上的 Nominatim 查询。

© www.soinside.com 2019 - 2024. All rights reserved.