在 OSmnx 中将街道划分为更小的部分

Dividing streets to smaller segments in OSmnx

是否可以在 OSmnx 中将街道划分为更小的部分?例如,假设我们想要将一条街道分成 10 米的段或将一条街道分成 10 个相等的部分。

G = ox.graph_from_place('Piedmont, California, USA', network_type='drive')
fig, ax = ox.plot_graph(G, node_zorder=2, node_color='w', bgcolor='k')

假设在这个例子中,我想在长度大于 50 米的街道上有 10 个等距的节点。这可能吗?我已经看过 OSmnx documentations 但我不确定是否存在此功能。

您可以使用 redistribute_vertices 函数细分道路的 几何形状 。然后,您必须在每个几何顶点手动创建图形节点。另请注意,您最初可以通过在创建图表时简单地传递 simplify=False 来获得更细粒度的图表。

编辑:请注意 redistribute_vertices 函数已被弃用。请改用 interpolate_points 函数:https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.utils_geo.interpolate_points