我如何丢下面包屑”沿着每米的边缘每米以在OSMNX中创建节点之间?
OSMNX 中是否有一种方法可以沿着投影图的每条边每 N 米添加中间节点?
我认为这在某种程度上与简化相反。
如果道路上有很长的弯道,节点仍然应该添加在弯道上,而不是像乌鸦飞一样。
import osmnx as ox
G = ox.graph_from_place('Cortlandt, New York', network_type='drive', simplify=True)
Gp = ox.project_graph(G)
nodes, edges = ox.graph_to_gdfs(Gp)
# nodes is a GeoDataFrame with GeoSeries of "osmid", "y", "x", "lat", "lon", "highway", and "geometry"
# this is awkward to reference
ls = edges["geometry"][191122010][3046769062]
length_m = edges["length"][191122010][3046769062][0]
d_m = 0
while d_m < length_m:
point = ls.interpolate(d_m)
node = ... # TODO
G.add_node(node)
d_m += 50
因此,问题是我如何创建一个与边缘上的其他节点具有相同属性但不使用 LineString 而是使用点的节点?我如何从插值点获得经纬度?
Is there a way in OSMNX to add inbetween nodes along each edge of a projected graph every N meters?
This is I suppose the opposite of simplification in a way.
If there's a long curve on a road, the nodes should still be added on the curve not as the crow flies.
import osmnx as ox
G = ox.graph_from_place('Cortlandt, New York', network_type='drive', simplify=True)
Gp = ox.project_graph(G)
nodes, edges = ox.graph_to_gdfs(Gp)
# nodes is a GeoDataFrame with GeoSeries of "osmid", "y", "x", "lat", "lon", "highway", and "geometry"
# this is awkward to reference
ls = edges["geometry"][191122010][3046769062]
length_m = edges["length"][191122010][3046769062][0]
d_m = 0
while d_m < length_m:
point = ls.interpolate(d_m)
node = ... # TODO
G.add_node(node)
d_m += 50
The question is thus how I do create a node that has the same attributes as other nodes on the edge but doesn't use a LineString but rather a point? And how would I get a lat, lon from the interpolated point?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论