-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
319 lines (283 loc) · 13.8 KB
/
app.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import dash as dash
import dash_core_components as dcc
import dash_html_components as html
# import geopandas as gpd
# import numpy as np
import pandas as pd
# import plotly.graph_objs as go
import plotly.express as px
import dash_bootstrap_components as dbc
import base64
# import mkl
# from components import home_button, news_button, city_bus_button, city_map_button
# Functions
# Initial Bootstrap
# https://towardsdatascience.com/python-for-data-science-bootstrap-for-plotly-dash-interactive-visualizations-c294464e3e0e
external_stylesheets = [dbc.themes.BOOTSTRAP]
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
PLOTLY_LOGO = "https://images.plot.ly/logo/new-branding/plotly-logomark.png"
# defining navbar items
## Data - Bus Ridership
cta_bus_ridership = pd.read_csv("CTA_-_Ridership_-_Bus_Routes_-_Daily_Totals_by_Route.csv")
cta_bus_ridership['Year'] = pd.DatetimeIndex(cta_bus_ridership['date']).year
# Drop 2020
cta_bus_ridership.drop(
cta_bus_ridership[cta_bus_ridership['Year']==2020].index, inplace=True
)
annual_cta_ridership = cta_bus_ridership.groupby('Year').sum()
# print(annual_cta_ridership)
ridership_graph = px.scatter(
annual_cta_ridership,
x=annual_cta_ridership.index,
y="rides",
title="Bus Ridership (2001 - 2019)",
labels={"rides" : "Number of Rides ( in Millions )"}
)
ridership_graph.update_layout(clickmode='event+select')
ridership_graph.update_traces(marker_size=20)
ridership_figure = html.Div([
dcc.Graph(
id="ridership",
figure=ridership_graph
)
])
# Save For Later - Just utilze the png version of the bus stops :(
# test_map = gpd.read_file("./Boundaries - City/geo_export_b127f319-53a1-4af3-924f-5b23c29c095c.shp")
# chi_bus_stops = gpd.read_file("./CTA_BusStops/CTA_BusStops.shp")
# chi_bus_stopMap = chi_bus_stops.plot(figsize=(30,30), markersize=2)
# chi_bus_stopMap.set_axis_off()
# Image of Bus Stops - Update to filter for certain routes?
busStopsImage = 'chi_busStops.png' # replace with your own image
encoded_busStopImage = base64.b64encode(open(busStopsImage, 'rb').read())
illinois_map_figure = html.Div([
html.Img(
src='data:image/png;base64,{}'.format(encoded_busStopImage.decode()),
style={ 'max-width': '100%'}
)
])
city_map_button = dbc.NavItem(
dbc.NavLink('City Map',
href="https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-City/ewy2-6yfk",
external_link=True,
className='navlinks')
)
city_bus_button = dbc.NavItem(
dbc.NavLink('Trend',
href="https://data.cityofchicago.org/browse?q=stops&sortBy=relevance",
external_link=True,
className='navlinks')
)
news_button = dbc.NavItem(
dbc.NavLink('Transportation Equity',
href="https://www.metroplanning.org/work/project/47/subpage/2",
external_link=True,
className='navlinks'))
ridership_figure_temp = html.Div([
dcc.Graph(
id="ridership2",
figure=ridership_graph
)
])
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# Use row and col to control vertical alignment of logo / brand
dbc.Row(
[
dbc.Col(dbc.NavbarBrand("Analytical Politics II", className="ml-2 work-sans")),
],
align="left",
no_gutters=True,
),
href="#home",
),
dbc.NavbarToggler(id="navbar-toggler"),
dbc.Collapse(
dbc.Nav(
[
city_map_button,
city_bus_button,
news_button
],className='ml-auto work-sans', navbar=True), id="navbar-collapse", navbar=True),
],
),
color="rgb(42,62,66)",
dark=True,
style = {'background-color':'#191919'},
className = 'navbar-change',
expand= 'lg'
)
group_info = dbc.Row(
[
dbc.Col([
dbc.Card(
dbc.ListGroup(
[
dbc.ListGroupItem("Joe Kensok"),
dbc.ListGroupItem("Jake Foose"),
dbc.ListGroupItem("Aidan Coffey"),
dbc.ListGroupItem("Sebastian Clavijo")
],
flush=True, className="align-self-center h-50"
),
style={"width": "100%"}, className="align-self-center h-50"
)
])], align="center"
)
problem_layout = dbc.Card(
dbc.CardBody(
[
html.H4("The Problem: ", className="card-title"),
dbc.ListGroup(
[
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("CTA Ridership is declining"),
dbc.ListGroupItemText("From 2012 to 2019, annual rides have declined by about 77.5 million."),
dbc.ListGroupItemText("With the stresses on the system from the COVID-19 pandemic, ridership stands to decline even further.")
]
),
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("City Hall has stopped supporting its public transportation"),
dbc.ListGroupItemText("The share of Chicago’s sales tax going to public transit has been cut in several of the past city budgets"),
dbc.ListGroupItemText("Taxes ostensibly designed to fund public transit have had a pitiful percentage earmarked for the CTA")
]
),
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("Chicago’s citizens do not choose to use public transit"),
dbc.ListGroupItemText("Chicago has not adequately proved to its citizens that the CTA is clean and safe in the wake of the COVID-19 pandemic."),
dbc.ListGroupItemText("30% of Chicago’s citizens live in Economically Disconected Areas where public transit is not even an option.")
]
)
]
)
]
),
style={"width": "100%", "height":"100%"},
)
solution_layout = dbc.Card(
dbc.CardBody(
[
html.H4("Our Solution: ", className="card-title"),
dbc.ListGroup(
[
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("Establish dedicated funding streams for the CTA through local taxes."),
dbc.ListGroupItemText("Earmark the entirety of Chicago’s rideshare tax earnings to the equitable development of the CTA."),
dbc.ListGroupItemText("Establish a local gas tax to both disincentivize driving in the city and encourage the increased use of public transit.")
]
),
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("Build 50 miles of bus lanes throughout the city"),
dbc.ListGroupItemText("Cities like Seattle, Los Angeles, and Denver have made buses faster and more reliable by instituting dedicated bus lanes throughout their cities."),
dbc.ListGroupItemText("Chicago can target these bus lanes to alleviate the inequities inherent in its 'Economically Disconnected Areas.'")
]
),
dbc.ListGroupItem(
[
dbc.ListGroupItemHeading("Begin a public education campaign focused on 'Equitable Transportation'"),
dbc.ListGroupItemText("A public education campaign will make more of Chicago’s citizens feel safe using the bus, helping spur a return to ridership."),
dbc.ListGroupItemText("With support of racial equity and social justice form, implementation will be both popular and effective.")
]
)
]
)
]
),
style={"width": "100%", "height":"100%"},
)
app.layout = html.Div(
children = [
navbar,
html.Div(
dbc.Row([
dbc.Col(
dbc.Jumbotron(
[
dbc.Container(
[
html.H1("P.S. I Bus You", className="display-2"),
html.P(
"How to fix an unsupported system of transportation and reconnect disconnected communities",
className="lead",
),
html.Hr(),
html.H6("by: Sebastian Clavijo, Aidan Coffey, Joe Kensok, Jake Foose")
],
fluid=True,
)
],
fluid=True,
),
width=10)
]
), className='container', style={"max-width":"90%"}
),
html.Div(
dbc.Row([
dbc.Col(
problem_layout, width=8),
dbc.Col(
dbc.Card(
dbc.CardBody(
[ridership_figure]
)
),
width=4)
]
)
,className = 'container', style={"max-width":"90%"}
),
html.Hr(),
html.Div(
dbc.Row(
[dbc.Col(
dbc.Card(
dbc.CardBody(
html.H6(
"A survey of individuals making $25,000 or less conducted by the Active Transportation Alliance found that 80% of respondents use the public transportation system to access their job. It is the people who rely on the public transportation system the most that are the most underserved. The City of Chicago has left over 30% of its citizens trapped without the means to help themselves."
, className="card-text lead"))
), width=12
)]
), className='container', style={"max-width":"90%"}
),
html.Hr(),
html.Div(
dbc.Row(
[
dbc.Col(
dbc.Card(
dbc.CardBody(illinois_map_figure)
), width = 4
),
dbc.Col(
solution_layout,
width= 8
)
]),
className='container',
style={"max-width":"90%"}),
html.Hr(),
html.Div(
dbc.Row(
[dbc.Col(
dbc.Card(
dbc.CardBody(
html.H6(
"By utilizing this money, Denver’s rail ridership has gone up, Los Angeles is considering making their public transit free, and Seattle’s public transit system has seen years of rapid growth. Chicago, on the other hand, has been reducing the proportion of sales tax being used for public transit for the past several years, deferring maintenance and capital improvement projects. If Chicago is serious about improving its transit system, it should improve the funding streams it has, implement new ones, and then commit to using that money for public transit.",
className="card-text lead")
)
), width=12
)]
), className="container", style={"max-width":"90%"}
),
html.Hr(),
]
, style={"background-color": "#e9ecef"})
if __name__ == '__main__':
app.run_server()