有没有办法从 OSM 仅下载车辆网络作为 .osm 文件?

Is there a way to download only vehicle networks from OSM as .osm file?

我只需要从 OSM 下载车辆网络,并让输出与正常的 .osm 文件一样,然后可以在 OSMnx 中使用(这将是相同或相似的,就像我所做的一样 osmnx.graph_from_place('Piedmont, CA, USA', network_type='drive')), 我尝试使用 OSMnx 来做到这一点并将图形保存为 .osm,但是从该文件加载时 SUMO 缺少大多数节点和边,所以我需要一些可以做到这一点的东西,同时保留原始的 .osm 文件结构,但仅是车辆网络(如果可能,使用 python)。

我读过:https://www.researchgate.net/publication/334767256_Road_network_extraction_with_OSMNx_and_SUMOPy

但我不知道如何使用 SUMOpy 并如图所示转换文件。

我们通常使用osmfilter,例如仅获取主要道路:

osmfilter input.osm --keep-ways="highway=primary =primary_link =secondary =secondary_link =trunk =trunk_link =motorway =motorway_link" --keep-nodes= --keep-relations= > output.osm