![]() |
The measure of entropy describes the heterogeneity of data. For street network modeling, the entropy reveals a city’s street order and disorder. Cities with high orientation entropy show that the streets are spread out as much as possible. While low orientation entropy means that the streets are nearly concentrated to a point. In this article, we will calculate the Undirected graph’s Orientation entropy using OSMnx bearing Module in Python. Syntax of osmnx.bearing.orientation_entropy() FunctionOrientation entropy is the entropy of its edges’ bidirectional bearings across evenly spaced bins. Ignores self-loop edges as their bearings are undefined.
Calculate Undirected Graph’s Orientation Entropy Using OSMnx Bearing ModuleBelow, are the step-by-step explanation of how to calculate undirected graph’s orientation entrophy using OSMnx bearing module in Python: Step 1: Visualize Street NetworkTo better understand city street orientation entropy, we can consider two popular cities – Thiruvananthapuram and Chicago. Let’s plot the layout of Thiruvananthapuram and Chicago. Sample code shown below:
Output: ![]() Comparison Chicago-Thiruvananthapuram Step 2: Convert to Undirected Graph and Add Edge BearingsAs a next step, let’s add all the bearings (and reciprocals) for all the edges in a city and divide them into 36 equal sized bins (each bin represents 10°).
Let’s take the multidigraph of Chicago. Convert the directed graph to the undirected graph and add edge bearing. Sample code as shown below:
Output: MultiEdgeDataView([(701660, 1223297118, 89.0), (701660, 8693882986, 82.7),
(702090, 261263104, 286.8), (702090, 1223297118, 280.8), (702090, 266800212, 102.5),
(20217442, 6423774545, 76.0), (25779161, 739968328, 161.2), (25779161, 26703891, 357.3),
(25779161, 9233026648, 347.1), (25779173, 709393016, 116.5), (25779173, 25779174, 130.2),
(25779173, 309816217, 327.1), ...])
Let check the number of bearings:
Output: 428965
Our entropy calculation function avoid self loop. So only bearings without self loop (u!=v) are considered. If min_length is provided, then the length of edges should be greater than the minimum length. If weight parameter is set, then the bearing data extends based on the weight for each edges (the edges must be weighted).
Output: 428066
Step 3: Orientation Distribution in Street NetworkWe can plot polar histogram (36 bins) to compare Chicago and Thiruvananthapuram. below code generates a polar histogram to visualize the orientation distribution of edges in the Chicago street network using OSMnx, with parameters specifying the number of bins, figure size, color, and other aesthetic properties.
Output: ![]() Polar histogram From the above polar histogram, we can conclude that the majority of streets in Chicago falls into just 4 bins centered on 0°, 90°, 180°, and 270°. Meanwhile, Thiruvananthapuram has nearly uniform distributions of street orientations around the compass. Step 4: Calculate Orientation EntropyOrientation Entropy for Chicago Now we are Calculating orientation entropy for the Chicago street network using OSMnx with specified parameters.
Output: 2.24709579954578
Orientation Entropy for Thiruvananthapuram Now we are Calculating orientation entropy for the Thiruvananthapuram street network using OSMnx with specified parameters.
Output: 3.565979382949194
|
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |