Код: Выделить всё
ox.graph_from_polygon => graph_to_gdfs => modify gdf_edges => ox.graph_from_gdfs => ox.simplify_graph
Код: Выделить всё
File .../osmnx/simplification.py:362, in simplify_graph(G, strict, edge_attrs_differ, endpoint_attrs, remove_rings, track_merged)
359 if attr in attrs_to_sum:
360 # if this attribute must be summed, sum it now
361 path_attributes[attr] = sum(path_attributes[attr])
--> 362 elif len(set(path_attributes[attr])) == 1:
363 # if there's only 1 unique value in this attribute list,
Код: Выделить всё
import shapely
import osmnx as ox
poly = shapely.from_wkt("POLYGON((9.493474960327147 51.228210969202365,"
"9.493346214294432 51.223359875812804,"
"9.498442411422728 51.22356145497176,"
"9.498571157455443 51.228036284963565,"
"9.493474960327147 51.228210969202365))")
G = ox.graph_from_polygon(poly, network_type="drive")
nodes_gdf, edges_gdf = ox.graph_to_gdfs(G.to_undirected())
G2 = ox.graph_from_gdfs(gdf_nodes=nodes_gdf, gdf_edges=edges_gdf)
nodes_gdf_2, edges_gdf_2 = ox.graph_to_gdfs(ox.simplify_graph(G2))
Подробнее здесь: https://stackoverflow.com/questions/792 ... -from-gdfs
Мобильная версия