-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (46 loc) · 1.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import osmnx as ox
def draw_map(lat, long, label, draw_distance=5000):
point = (lat, long)
G = ox.graph_from_point(point, dist=draw_distance, retain_all=True, simplify=True, network_type='drive')
data = []
for uu, vv, kkey, ddata in G.edges(keys=True, data=True):
data.append(ddata)
road_colors = []
road_widths = []
for item in data:
if "length" in item.keys():
if item["length"] <= 100:
linewidth = 0.90
color = "#11999E"
elif item["length"] > 100 and item["length"] <= 200:
linewidth = 0.76
color = "#11999E"
elif item["length"] > 200 and item["length"] <= 420:
linewidth = 1.10
color = "#11999E"
elif item["length"] > 420:
color = "#D8D860"
linewidth = 2.00
else:
color = "#888888"
linewidth = 0.95
else:
color = "#A0AECD"
linewidth = 0.10
road_colors.append(color)
road_widths.append(linewidth)
bgcolor = "#1D5464"
fig, ax = ox.plot_graph(G, node_size=0, figsize=(27, 40),
dpi=200, bgcolor=bgcolor,
save=False, edge_color=road_colors,
edge_linewidth=road_widths, edge_alpha=1)
"""ax.set_title(label, fontdict=
{'fontsize': '60',
'color': '#D8D860',
'verticalalignment': 'center',
'horizontalalignment': 'center'}
)
"""
fig.tight_layout(pad=0)
fig.savefig("map.png", dpi=200, bbox_inches='tight', format="png", facecolor=fig.get_facecolor(), transparent=False)
draw_map(43.466667, -80.516670, 'Waterloo driving roads', 13000)