'Dividing streets to smaller segments in OSmnx
Is it possible to divide street segments to smaller parts in OSmnx? For instance let's say we want to divide a street in 10 meter segments or divide a street into 10 equal parts.
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')
Let's say in this example, I want to have 10 nodes, equally distanced, in streets whose lengths are greater than 50 meter. Is this possible? I have already looked at OSmnx documentations but I am not sure if this feature exists.
Solution 1:[1]
You can subdivide the road's geometry like that by using the redistribute_vertices function. You would then have to manually create graph nodes at each geometry vertex. Note also that you can get a finer grained graph initially by simply passing simplify=False
when you create the graph.
EDIT: note that the redistribute_vertices
function has since been deprecated. Use the interpolate_points
function instead: https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.utils_geo.interpolate_points
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |