using PyCall
@pyimport osmnx as ox
@pyimport networkx as nx
@pyimport geopandas as gpd
@pyimport matplotlib.pyplot as plt
@pyimport pandas as pd
function getRoadGraph()
place_name = "Beijing, China"
graph = ox.graph_from_place(place_name, network_type = "drive") # type: networkx.classes.multidigraph.MultiDigraph
return graph
end
# return a list of nodes along the route
function getRoute(graph, sourceLocX::Float, sourceLocY::Float, sinkLocX::Float, sinkLocY::Float)
# @import osmnx as ox
# @import networkx as nx
graph_proj = ox.project_graph(graph) # reprojecting data into UTM
orig_yx = (sourceLocY, sourceLocX) # orig point
target_yx = (sinkLocY, sinkLocX) # target point
# find the nearest node to the point/location orig_yx
orig_node = ox.get_nearest_node(graph_proj, orig_yx, method="euclidean")
# find the nearest node to the point/location target_yx
target_node = ox.get_nearest_node(graph_proj, target_yx, method = "euclidean" )
route = nx.shortest_path(G=graph_proj, source=orig_node, target=target_node, weight='length')
return route
end
g=getRoadGraph()
Could anyone please help me out?