我如何丢下面包屑”沿着每米的边缘每米以在OSMNX中创建节点之间?

发布于 2025-01-20 04:36:51 字数 910 浏览 0 评论 0原文

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.

like this

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文