Traffic Congestion Analysis

In [1]:
# Please skip reading all sections marked as In[1..10]
import matplotlib.pyplot as plt
import seaborn as sb
import mh_db as db
import mh_lib as ml
from IPython.display import display, HTML
%matplotlib inline
df_all, df_path, path_info = ml.get_df_path_segments(db, './csv/dec-05-to-dec-09-2016.csv', path_id=1)
Route : Mahadevapura - RMZ Ecospace
Analysis period: Mon 05-12-16 07:00AM to Fri 09-12-16 11:01AM
Map data 2016 (c) Google
Analysis data 2016 (c) MapsHalli

1. Top three congested week days for the route

1.1 Route congestion details and maps

In [2]:
HTML(data = ml.show_congested_paths(df_path))
Out[2]:

#1. Route @ Friday 09:00AM

Distance: 8.43 km
Duration - Expected: 10:40 min:sec | Actual: 44:57 min:sec | Lost: 34:17 min:sec
Speed - Expected: 48 km/h | Actual: 11 km/h
Approximate Congestion Time:  Friday 09:00AM
View Route in Google Maps

#2. Route @ Tuesday 10:21AM

Distance: 8.43 km
Duration - Expected: 10:40 min:sec | Actual: 42:41 min:sec | Lost: 32:01 min:sec
Speed - Expected: 48 km/h | Actual: 12 km/h
Approximate Congestion Time:  Tuesday 10:21AM
View Route in Google Maps

#3. Route @ Monday 09:20AM

Distance: 8.43 km
Duration - Expected: 10:40 min:sec | Actual: 38:48 min:sec | Lost: 28:08 min:sec
Speed - Expected: 48 km/h | Actual: 13 km/h
Approximate Congestion Time:  Monday 09:20AM
View Route in Google Maps

1.2 Route travel time (duration) and speeds

In [3]:
ml.show_congested_path_graphs(df_all, plt=plt)
Route on the most congested day
Day of week: Friday

2. Top three congested segments in the route

2.1 Segment congestion details and maps

In [4]:
HTML(data = ml.show_congested_segments(df_all, method='mean'))
Out[4]:

#1. Segment 4 @ Wednesday 09:21AM

Distance: 0.48 km
Duration - Expected: 57 sec | Actual: 12:14 min:sec | Lost: 11:16 min:sec
Speed - Expected: 30 km/h | Actual: 2 km/h
Approximate Congestion Time:  Wednesday 09:21AM
View Segment 4 in Google Maps

#2. Segment 2 @ Friday 10:11AM

Distance: 0.68 km
Duration - Expected: 01:02 min:sec | Actual: 12:26 min:sec | Lost: 11:23 min:sec
Speed - Expected: 39 km/h | Actual: 3 km/h
Approximate Congestion Time:  Friday 10:11AM
View Segment 2 in Google Maps

#3. Segment 3 @ Friday 09:00AM

Distance: 0.43 km
Duration - Expected: 50 sec | Actual: 08:28 min:sec | Lost: 07:38 min:sec
Speed - Expected: 31 km/h | Actual: 3 km/h
Approximate Congestion Time:  Friday 09:00AM
View Segment 3 in Google Maps

2.2 Congested segment travel time (duration) and speeds

In [5]:
ml.show_congested_segment_graphs(df_all, plt=plt, method='mean')
#1 most congested segment on the most congested day of week for the segment
Segment : 4
In [6]:
ml.show_congested_segment_graphs(df_all, plt=plt, method='mean', index=1)
#2 most congested segment on the most congested day of week for the segment
Segment : 2
In [7]:
ml.show_congested_segment_graphs(df_all, plt=plt, method='mean', index=2)
#3 most congested segment on the most congested day of week for the segment
Segment : 3