在OSMNX图中找到连接的节点到特定节点
我使用 osmnx 创建了一个图表。并检索该图中存在的所有节点。现在我想找到到特定节点的连接节点。我想知道osmnx或networkx中是否有任何方法可以做到这一点?或任何其他方式。我的代码如下。
import pandas as pd
import geopandas as gpd
import osmnx as ox
#Defining top corners
top = gpd.GeoDataFrame(columns = ['name', 'geometry'], crs = 4326, geometry = 'geometry')
top.at[0, 'geometry'] = Point(100.49209048590119,13.808722580927133)
top.at[0, 'name'] = 'tl'
top.at[1, 'geometry'] = Point(100.58494841499845, 13.809076204778961)
top.at[1, 'name'] = 'tr'
# Defining Bottom corners
bottom = gpd.GeoDataFrame(columns = ['name', 'geometry'], crs = 4326, geometry = 'geometry')
bottom.at[0, 'geometry'] = Point(100.49141790672476,13.714053001208732)
bottom.at[0, 'name'] = 'bl'
bottom.at[1, 'geometry'] = Point(100.58476136747744, 13.717826488187361)
bottom.at[1, 'name'] = 'br'
#creating road network
combined = top.append(bottom)
convex = combined.unary_union.convex_hull
graph_extent = convex.buffer(0.02)
graph = ox.graph_from_polygon(graph_extent, network_type= "drive",custom_filter='["highway"!~"|secondary|residential|unclassified|tertiary"]')
#saving projection
graph_proj = ox.project_graph(graph)
edges = ox.graph_to_gdfs(graph_proj, nodes=False)
CRS = edges.crs
nodes = ox.graph_to_gdfs(graph_proj, edges=False)
node_specific = [(100.4923576731243,13.70365525026876),(100.4721408793079,13.72276049159698)]
I have created a graph using osmnx. and retrieved all the nodes that exist in that graph. now I want to find the connecting nodes to a specific node. I wonder if there is any method in osmnx or networkx to do so? or any other way. my code is as below.
import pandas as pd
import geopandas as gpd
import osmnx as ox
#Defining top corners
top = gpd.GeoDataFrame(columns = ['name', 'geometry'], crs = 4326, geometry = 'geometry')
top.at[0, 'geometry'] = Point(100.49209048590119,13.808722580927133)
top.at[0, 'name'] = 'tl'
top.at[1, 'geometry'] = Point(100.58494841499845, 13.809076204778961)
top.at[1, 'name'] = 'tr'
# Defining Bottom corners
bottom = gpd.GeoDataFrame(columns = ['name', 'geometry'], crs = 4326, geometry = 'geometry')
bottom.at[0, 'geometry'] = Point(100.49141790672476,13.714053001208732)
bottom.at[0, 'name'] = 'bl'
bottom.at[1, 'geometry'] = Point(100.58476136747744, 13.717826488187361)
bottom.at[1, 'name'] = 'br'
#creating road network
combined = top.append(bottom)
convex = combined.unary_union.convex_hull
graph_extent = convex.buffer(0.02)
graph = ox.graph_from_polygon(graph_extent, network_type= "drive",custom_filter='["highway"!~"|secondary|residential|unclassified|tertiary"]')
#saving projection
graph_proj = ox.project_graph(graph)
edges = ox.graph_to_gdfs(graph_proj, nodes=False)
CRS = edges.crs
nodes = ox.graph_to_gdfs(graph_proj, edges=False)
node_specific = [(100.4923576731243,13.70365525026876),(100.4721408793079,13.72276049159698)]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已经简化了您的代码来生成凸形船体。
连接的节点 - 不确定您
sjoin()
最近的_nodes()
显示了
Shortest_path()
显示了
Have simplified your code for generating a convex hull of points.
Connected nodes - not sure which you are defining
sjoin()
nearest_nodes()
shortest_path()