You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用OSMnx获取hov与toll标签值的技术咨询

如何用OSMnx获取hov和toll标签数值

我想咨询如何使用OSMnx获取hov标签和toll标签的数值,以下是我的初始代码:

import osmnx as ox
import networkx as nx

import numpy as np
import pandas as pd

from pandas import Series, DataFrame

cf = '["highway"~"motorway"]'

G = ox.graph_from_place("Los Angeles County, California, USA", network_type="drive", custom_filter=cf)

G = ox.add_edge_bearings(G)

gdf_edges = ox.graph_to_gdfs(G, nodes=False)
df=pd.DataFrame(gdf_edges).reset_index()
df.columns

初始输出的列名如下:
初始输出列名

可以看到结果中没有名为hov或toll的列,因此我想了解如何判断某段高速公路(即边)是否为hov车道或收费道路。

感谢@gboeing的回复,我通过以下代码成功添加了这两个标签:

import osmnx as ox
import networkx as nx

import numpy as np
import pandas as pd

from pandas import Series, DataFrame

ox.settings.useful_tags_way += ["hov"]
ox.settings.useful_tags_way += ["toll"]

cf = '["highway"~"motorway"]'

G = ox.graph_from_place("Los Angeles County, California, USA", network_type="drive", custom_filter=cf)

G = ox.add_edge_bearings(G)

gdf_edges = ox.graph_to_gdfs(G, nodes=False)
df=pd.DataFrame(gdf_edges).reset_index()
df.columns

添加标签后的输出列名如下:
添加标签后的输出列名

内容的提问来源于stack exchange,提问作者Z. G.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 09:43:31