【问题标题】:How to remove edges in OSMnx如何在 OSMnx 中去除边缘
【发布时间】:2020-12-02 18:27:20
【问题描述】:

关于从 osmnx 网络中删除边的问题。

我写了下面的代码,用下面的例子来分析。 例如:https://github.com/gboeing/osmnx-examples/blob/master/notebooks/13-isolines-isochrones.ipynb

我的代码

import geopandas as gpd
import matplotlib.pyplot as plt
import networkx as nx
import osmnx as ox
from descartes import PolygonPatch
from shapely.geometry import Point, LineString, Polygon
%matplotlib inline
ox.config(log_console=True, use_cache=True)

point = 35.334023, 129.314150
network_type = 'drive'
trip_times = [10, 20, 30, 40] #in minutes
travel_speed = 20 #walking speed in km/hour

# download the street network
G = ox.graph_from_point(point, network_type='drive', dist=8000)
ox.plot_graph(G, node_size=1, edge_color='#999999', node_color='#dc4343', edge_linewidth=0.5, figsize=(15, 20))

在这里,我想从配置的网络中删除特定的边缘。 例如

edges = edges.loc[edges['name'].str.contains("천산로")==False]

还没有解决这些问题。如果您能给我一个好的答案,我将不胜感激。

【问题讨论】:

  • 我建议您阅读 OSMnx 文档,尤其是 NetworkX 文档,因为从图中删除边是基本功能。

标签: python osmnx


【解决方案1】:

您可以遍历所有图形边,检查边名称,然后在适用时删除边:

for u, v, name in nxG.edges(name='name'):
    if name == 'some_name': nxG.remove_edge(u, v)

【讨论】:

    猜你喜欢
    • 2012-07-09
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 1970-01-01
    • 2020-06-24
    • 1970-01-01
    相关资源
    最近更新 更多