<jupyter_start><jupyter_text>Street network bearingsTaking Binjiang as an example, calculate street network bearings and visualize the spatial orientation of a street network.<jupyter_code>import osmnx as ox, pandas as pd, matplotlib.pyplot as plt
%matplotlib inline
ox.config(log_console=True, use_cache=True)<jupyter_output><empty_output><jupyter_text>First, look at a non-grid street network<jupyter_code>G = ox.graph_from_place('Binjiang District, Hangzhou City, China', network_type='drive')
fig, ax = ox.plot_graph(ox.project_graph(G), node_size=0)
G = ox.add_edge_bearings(G)
data = pd.Series([data for u, v, k, data in G.edges(keys=True, data=True)])
data[0]
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('Binjiang District street network edge bearings')
plt.show()

# 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('Binjiang District edge bearings', y=1.1)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1376281112737921, 'fraction_numerical': 0.024158125915080528, 'mean_word_length': 6.552486187845304, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '51227', 'license': 'MIT', 'n_tokens_mistral': 528, 'n_tokens_neox': 490, 'n_words': 126, 'path': 'edge-subdivision/notebook/bearings.ipynb', 'repo_name': 'sunmengnan/city_brain', 'size': '1366'}