LoginSignup
1
0

More than 3 years have passed since last update.

OSMnxで取得した道路ネットワークデータから極座標グラフを作ろう!

Last updated at Posted at 2019-10-12

道路ネットワークの取得

道路ネットワークの取得方法は、前回の記事↓↓↓を参考にしてください。
OSMnxを用いて,オープンストリートマップから道路ネットワークデータを取得しよう。

前回取得した道路ネットワークデータの可視化結果(横浜市)

yokohama.png

このデータを元に、方向ごとに集計して可視化していきます。

今回つくるもの:極座標グラフ

city_road.jpg

世界各都市の道路が向いている方角が可視化されたグラフを比べてみると何がわかるのか?

データの分布

bearingdata.py
import pandas as pd
import osmnx as ox
import matplotlib.pyplot as plt

G = ox.graph_from_place(f'Yokohama, Kanagawa, Japan', network_type='drive')

# calculate edge bearings and visualize their frequency
G = ox.add_edge_bearings(G)
bearings = pd.Series([data['bearing'] for u, v, k, data in G.edges(keys=True, data=True)])
ax = bearings.hist(bins=30, zorder=2, alpha=0.8)
xlim = ax.set_xlim(0, 360)
ax.set_title('street network bar chart')
plt.show()

横浜市の道路の方向データ

bearing_data_yokohama.png

極座標の作成

bearingplot.py
# polar plot
import numpy as np
n = 30
count, division = np.histogram(bearings, bins=[ang*360/n for ang in range(0,n+1)])
division = division[0:-1]
width =  2 * np.pi/n
ax = plt.subplot(111, projection='polar')
ax.set_theta_zero_location('N')
ax.set_theta_direction('clockwise')
bars = ax.bar(division * np.pi/180 - width * 0.5 , count, width=width, bottom=0.0)
ax.set_title('street network polar coordinates', y=1.1)
plt.show()

横浜市の道路の方向の極座標グラフ

bearing_graph_yokohama.png

他の市でもやってみました。

千葉市
ChibaCity.png

福岡市
FukuokaCity.png

那覇市
NahaCity.png

 

まとめ

いかがでしょうか。今回は横浜市を例に可視化してみました。
もっといろいろな都市を可視化して比べてみたいですね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0