pip install osmnx
import networkx as nx
import osmnx as ox
import requests
import matplotlib.cm as cm
import matplotlib.colors as colors
ox.config(use_cache=True, log_console=True)
ox.__version__
import pyproj as pyproj
pyproj.__version__
from pyproj import Proj, transform
import numpy as np
import pandas as pd
# UTM-K
proj_UTMK = Proj(init='epsg:5178') # UTM-K(Bassel) 도로명주소 지도 사용 중
# WGS1984
proj_WGS84 = Proj(init='epsg:4326') # Wgs84 경도/위도, GPS사용 전지구 좌표
G = ox.graph_from_place('서울, 대한민국', network_type='drive')
fig, ax = ox.plot_graph(G)
orig = list(G)[0]
dest = list(G)[120]
# 거리 기반 최단경로 1개 탐색
route = ox.shortest_path(G, orig, dest, weight='length')
fig1_1, ax = ox.plot_graph_route(G, route, route_color='y', route_linewidth=6, node_size=0.5)
# calculate two routes by minimizing travel distance vs travel time
orig = list(G)[1]
dest = list(G)[120]
route1 = ox.shortest_path(G, orig, dest, weight='length')
route2 = ox.shortest_path(G, orig, dest, weight='travel_time')
# plot the routes
fig2, ax = ox.plot_graph_routes(G, routes=[route1, route2], route_colors=['r', 'y'], route_linewidth=6, node_size=0)
ox.distance.nearest_nodes(G, orig , dest, return_dist=False)
Like this:
Like Loading...
Related