如何在OSMnx中删除边缘



有关从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]

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

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

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

最新更新