add more geogs
Browse files- app.py +301 -37
- data/.DS_Store +0 -0
app.py
CHANGED
|
@@ -42,6 +42,158 @@ population_2020_data = {
|
|
| 42 |
# Create a DataFrame for the top 15 counties
|
| 43 |
df_population_2020 = pd.DataFrame(population_2020_data)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
# Function to create the bar plot for 2020 Tennessee population (top 15 counties)
|
| 46 |
def plot_2020_population_top15():
|
| 47 |
fig = px.bar(df_population_2020,
|
|
@@ -71,6 +223,18 @@ cbg_geographic_data = pd.read_csv("data/cbg_geographic_data.csv")
|
|
| 71 |
counties_geo = gpd.read_file("data/county/01_county-shape-file.shp")
|
| 72 |
counties_geo = counties_geo[counties_geo['statefp'] == '47'] # Filter for Tennessee
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# Define business types
|
| 75 |
df_md_final1['business_type'] = np.where(df_md_final1['name'].str.contains("Autozone", case=False, na=False), "Autozone",
|
| 76 |
np.where(df_md_final1['name'].str.contains("Napa Auto Parts", case=False, na=False), "Napa Auto Parts",
|
|
@@ -80,16 +244,101 @@ df_md_final1['business_type'] = np.where(df_md_final1['name'].str.contains("Auto
|
|
| 80 |
"Car Dealership",
|
| 81 |
"Other Auto Repair Shop")))))
|
| 82 |
|
| 83 |
-
# Function to create a Folium map with
|
| 84 |
-
def
|
| 85 |
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 86 |
|
| 87 |
-
#
|
|
|
|
|
|
|
|
|
|
| 88 |
filtered_df = df_md_final1
|
| 89 |
if business_filter != "All":
|
| 90 |
-
filtered_df =
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Define marker colors based on business type
|
| 95 |
def get_marker_color(business_type):
|
|
@@ -144,36 +393,36 @@ with gr.Blocks() as app:
|
|
| 144 |
datatype=["str", "str", "str", "str", "str"],
|
| 145 |
value=[
|
| 146 |
["AutoZone", "257 Wears Valley Rd", "Pigeon Forge", "Tennessee", "37863"],
|
| 147 |
-
["Sterling Auto", "2064 Wilma Rudolph Blvd", "Clarksville", "Tennessee", "37040"],
|
| 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 |
gr.Markdown("Source: Yellowbook")
|
|
@@ -182,11 +431,26 @@ with gr.Blocks() as app:
|
|
| 182 |
with gr.Tab("Auto repair shops in TN Counties"):
|
| 183 |
business_options = ["All"] + list(df_md_final1['business_type'].unique())
|
| 184 |
business_filter = gr.Dropdown(label="Select Business Type", choices=business_options, value="All")
|
| 185 |
-
|
| 186 |
|
| 187 |
with gr.Tab("Auto Repair Shops in TN Zip Codes"):
|
| 188 |
zip_options = ["All"] + list(df_md_final1['zip_code'].unique())
|
| 189 |
zip_filter = gr.Dropdown(label="Select Zip Code", choices=zip_options, value="All")
|
| 190 |
map_output_zip = gr.HTML(lambda zip_filter: create_map(business_filter="All", county_filter=zip_filter), inputs=[zip_filter])
|
| 191 |
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Create a DataFrame for the top 15 counties
|
| 43 |
df_population_2020 = pd.DataFrame(population_2020_data)
|
| 44 |
|
| 45 |
+
# Function to create a Folium map with county boundaries and markers
|
| 46 |
+
def create_map(county_filter="All", business_filter="All"):
|
| 47 |
+
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 48 |
+
|
| 49 |
+
# Filter based on business name
|
| 50 |
+
filtered_df = df_md_final1
|
| 51 |
+
if business_filter != "All":
|
| 52 |
+
filtered_df = filtered_df[df_md_final1['business_type'] == business_filter]
|
| 53 |
+
|
| 54 |
+
folium.GeoJson(counties_geo).add_to(m)
|
| 55 |
+
|
| 56 |
+
# Define marker colors based on business type
|
| 57 |
+
def get_marker_color(business_type):
|
| 58 |
+
colors = {
|
| 59 |
+
"Autozone": "lightblue",
|
| 60 |
+
"Napa Auto Parts": "lightgreen",
|
| 61 |
+
"O'Reilly Auto Parts": "orange",
|
| 62 |
+
"Advance Auto Parts": "yellow",
|
| 63 |
+
"Car Dealership": "red",
|
| 64 |
+
"Other Auto Repair Shop": "purple"
|
| 65 |
+
}
|
| 66 |
+
return colors.get(business_type, "blue")
|
| 67 |
+
|
| 68 |
+
for _, row in filtered_df.iterrows():
|
| 69 |
+
folium.Marker(
|
| 70 |
+
location=[row['md_y'], row['md_x']],
|
| 71 |
+
popup=row['name'],
|
| 72 |
+
icon=folium.Icon(color=get_marker_color(row['business_type']))
|
| 73 |
+
).add_to(m)
|
| 74 |
+
|
| 75 |
+
# Add the legend to the map
|
| 76 |
+
legend_html = '''
|
| 77 |
+
<div style="position: fixed;
|
| 78 |
+
bottom: 50px; left: 50px; width: 300px; height: 210px;
|
| 79 |
+
background-color: white; z-index:9999; font-size:14px;
|
| 80 |
+
border:2px solid grey;
|
| 81 |
+
padding: 10px;">
|
| 82 |
+
<b>Business Type</b><br>
|
| 83 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightblue"></i> Autozone<br>
|
| 84 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightgreen"></i> Napa Auto Parts<br>
|
| 85 |
+
<i class="fa fa-map-marker fa-2x" style="color:orange"></i> O'Reilly Auto Parts<br>
|
| 86 |
+
<i class="fa fa-map-marker fa-2x" style="color:yellow"></i> Advance Auto Parts<br>
|
| 87 |
+
<i class="fa fa-map-marker fa-2x" style="color:red"></i> Car Dealership<br>
|
| 88 |
+
<i class="fa fa-map-marker fa-2x" style="color:purple"></i> Other Auto Repair Shop<br>
|
| 89 |
+
</div>
|
| 90 |
+
'''
|
| 91 |
+
m.get_root().html.add_child(Element(legend_html))
|
| 92 |
+
|
| 93 |
+
return m._repr_html_()
|
| 94 |
+
|
| 95 |
+
# Function to create a Folium map with HSA boundaries and markers
|
| 96 |
+
def create_hsa_map(business_filter="All"):
|
| 97 |
+
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 98 |
+
|
| 99 |
+
# Add HSA boundaries
|
| 100 |
+
folium.GeoJson(hsa_geo).add_to(m)
|
| 101 |
+
|
| 102 |
+
# Filter businesses by selected type
|
| 103 |
+
filtered_df = df_md_final1
|
| 104 |
+
if business_filter != "All":
|
| 105 |
+
filtered_df = df_md_final1[df_md_final1['business_type'] == business_filter]
|
| 106 |
+
|
| 107 |
+
# Define marker colors based on business type
|
| 108 |
+
def get_marker_color(business_type):
|
| 109 |
+
colors = {
|
| 110 |
+
"Autozone": "lightblue",
|
| 111 |
+
"Napa Auto Parts": "lightgreen",
|
| 112 |
+
"O'Reilly Auto Parts": "orange",
|
| 113 |
+
"Advance Auto Parts": "yellow",
|
| 114 |
+
"Car Dealership": "red",
|
| 115 |
+
"Other Auto Repair Shop": "purple"
|
| 116 |
+
}
|
| 117 |
+
return colors.get(business_type, "blue")
|
| 118 |
+
|
| 119 |
+
for _, row in filtered_df.iterrows():
|
| 120 |
+
folium.Marker(
|
| 121 |
+
location=[row['md_y'], row['md_x']],
|
| 122 |
+
popup=row['name'],
|
| 123 |
+
icon=folium.Icon(color=get_marker_color(row['business_type']))
|
| 124 |
+
).add_to(m)
|
| 125 |
+
|
| 126 |
+
# Add the legend to the map
|
| 127 |
+
legend_html = '''
|
| 128 |
+
<div style="position: fixed;
|
| 129 |
+
bottom: 50px; left: 50px; width: 300px; height: 210px;
|
| 130 |
+
background-color: white; z-index:9999; font-size:14px;
|
| 131 |
+
border:2px solid grey;
|
| 132 |
+
padding: 10px;">
|
| 133 |
+
<b>Business Type</b><br>
|
| 134 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightblue"></i> Autozone<br>
|
| 135 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightgreen"></i> Napa Auto Parts<br>
|
| 136 |
+
<i class="fa fa-map-marker fa-2x" style="color:orange"></i> O'Reilly Auto Parts<br>
|
| 137 |
+
<i class="fa fa-map-marker fa-2x" style="color:yellow"></i> Advance Auto Parts<br>
|
| 138 |
+
<i class="fa fa-map-marker fa-2x" style="color:red"></i> Car Dealership<br>
|
| 139 |
+
<i class="fa fa-map-marker fa-2x" style="color:purple"></i> Other Auto Repair Shop<br>
|
| 140 |
+
</div>
|
| 141 |
+
'''
|
| 142 |
+
m.get_root().html.add_child(Element(legend_html))
|
| 143 |
+
|
| 144 |
+
return m._repr_html_()
|
| 145 |
+
|
| 146 |
+
# Function to create a Folium map with HRR boundaries and markers
|
| 147 |
+
def create_hrr_map(business_filter="All"):
|
| 148 |
+
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 149 |
+
|
| 150 |
+
# Add HRR boundaries
|
| 151 |
+
folium.GeoJson(hrr_geo).add_to(m)
|
| 152 |
+
|
| 153 |
+
# Filter businesses by selected type
|
| 154 |
+
filtered_df = df_md_final1
|
| 155 |
+
if business_filter != "All":
|
| 156 |
+
filtered_df = df_md_final1[df_md_final1['business_type'] == business_filter]
|
| 157 |
+
|
| 158 |
+
# Define marker colors based on business type
|
| 159 |
+
def get_marker_color(business_type):
|
| 160 |
+
colors = {
|
| 161 |
+
"Autozone": "lightblue",
|
| 162 |
+
"Napa Auto Parts": "lightgreen",
|
| 163 |
+
"O'Reilly Auto Parts": "orange",
|
| 164 |
+
"Advance Auto Parts": "yellow",
|
| 165 |
+
"Car Dealership": "red",
|
| 166 |
+
"Other Auto Repair Shop": "purple"
|
| 167 |
+
}
|
| 168 |
+
return colors.get(business_type, "blue")
|
| 169 |
+
|
| 170 |
+
for _, row in filtered_df.iterrows():
|
| 171 |
+
folium.Marker(
|
| 172 |
+
location=[row['md_y'], row['md_x']],
|
| 173 |
+
popup=row['name'],
|
| 174 |
+
icon=folium.Icon(color=get_marker_color(row['business_type']))
|
| 175 |
+
).add_to(m)
|
| 176 |
+
|
| 177 |
+
# Add the legend to the map
|
| 178 |
+
legend_html = '''
|
| 179 |
+
<div style="position: fixed;
|
| 180 |
+
bottom: 50px; left: 50px; width: 300px; height: 210px;
|
| 181 |
+
background-color: white; z-index:9999; font-size:14px;
|
| 182 |
+
border:2px solid grey;
|
| 183 |
+
padding: 10px;">
|
| 184 |
+
<b>Business Type</b><br>
|
| 185 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightblue"></i> Autozone<br>
|
| 186 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightgreen"></i> Napa Auto Parts<br>
|
| 187 |
+
<i class="fa fa-map-marker fa-2x" style="color:orange"></i> O'Reilly Auto Parts<br>
|
| 188 |
+
<i class="fa fa-map-marker fa-2x" style="color:yellow"></i> Advance Auto Parts<br>
|
| 189 |
+
<i class="fa fa-map-marker fa-2x" style="color:red"></i> Car Dealership<br>
|
| 190 |
+
<i class="fa fa-map-marker fa-2x" style="color:purple"></i> Other Auto Repair Shop<br>
|
| 191 |
+
</div>
|
| 192 |
+
'''
|
| 193 |
+
m.get_root().html.add_child(Element(legend_html))
|
| 194 |
+
|
| 195 |
+
return m._repr_html_()
|
| 196 |
+
|
| 197 |
# Function to create the bar plot for 2020 Tennessee population (top 15 counties)
|
| 198 |
def plot_2020_population_top15():
|
| 199 |
fig = px.bar(df_population_2020,
|
|
|
|
| 223 |
counties_geo = gpd.read_file("data/county/01_county-shape-file.shp")
|
| 224 |
counties_geo = counties_geo[counties_geo['statefp'] == '47'] # Filter for Tennessee
|
| 225 |
|
| 226 |
+
# Load the ZCTA shapefile
|
| 227 |
+
zcta_geo = gpd.read_file("data/tl_2020_us_zcta520/tl_2020_us_zcta520.shp")
|
| 228 |
+
zcta_geo = zcta_geo[zcta_geo['ZCTA5CE20'].str.startswith('37')] # Filter for Tennessee
|
| 229 |
+
|
| 230 |
+
# Load the HSA shapefile
|
| 231 |
+
hsa_geo = gpd.read_file("data/hsa/01_hsa-shape-file.shp")
|
| 232 |
+
hsa_geo = hsa_geo[hsa_geo['hsastate'] == 'TN']
|
| 233 |
+
|
| 234 |
+
# Load the HRR shapefile
|
| 235 |
+
hrr_geo = gpd.read_file("data/hrr/01_hrr-shape-file.shp")
|
| 236 |
+
hrr_geo = hrr_geo[hrr_geo['hrrstate'] == 'TN']
|
| 237 |
+
|
| 238 |
# Define business types
|
| 239 |
df_md_final1['business_type'] = np.where(df_md_final1['name'].str.contains("Autozone", case=False, na=False), "Autozone",
|
| 240 |
np.where(df_md_final1['name'].str.contains("Napa Auto Parts", case=False, na=False), "Napa Auto Parts",
|
|
|
|
| 244 |
"Car Dealership",
|
| 245 |
"Other Auto Repair Shop")))))
|
| 246 |
|
| 247 |
+
# Function to create a Folium map with ZCTA boundaries and auto business markers
|
| 248 |
+
def create_zcta_map(business_filter="All"):
|
| 249 |
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 250 |
|
| 251 |
+
# Add ZCTA boundaries
|
| 252 |
+
folium.GeoJson(zcta_geo).add_to(m)
|
| 253 |
+
|
| 254 |
+
# Filter businesses by selected type
|
| 255 |
filtered_df = df_md_final1
|
| 256 |
if business_filter != "All":
|
| 257 |
+
filtered_df = df_md_final1[df_md_final1['business_type'] == business_filter]
|
| 258 |
|
| 259 |
+
# Define marker colors based on business type
|
| 260 |
+
def get_marker_color(business_type):
|
| 261 |
+
colors = {
|
| 262 |
+
"Autozone": "lightblue",
|
| 263 |
+
"Napa Auto Parts": "lightgreen",
|
| 264 |
+
"O'Reilly Auto Parts": "orange",
|
| 265 |
+
"Advance Auto Parts": "yellow",
|
| 266 |
+
"Car Dealership": "red",
|
| 267 |
+
"Other Auto Repair Shop": "purple"
|
| 268 |
+
}
|
| 269 |
+
return colors.get(business_type, "blue")
|
| 270 |
+
|
| 271 |
+
for _, row in filtered_df.iterrows():
|
| 272 |
+
folium.Marker(
|
| 273 |
+
location=[row['md_y'], row['md_x']],
|
| 274 |
+
popup=row['name'],
|
| 275 |
+
icon=folium.Icon(color=get_marker_color(row['business_type']))
|
| 276 |
+
).add_to(m)
|
| 277 |
+
|
| 278 |
+
return m._repr_html_()
|
| 279 |
+
|
| 280 |
+
# Function to create a Folium map with HSA boundaries and auto business markers
|
| 281 |
+
def create_hsa_map_filtered(business_filter="All"):
|
| 282 |
+
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 283 |
+
|
| 284 |
+
# Add HSA boundaries
|
| 285 |
+
folium.GeoJson(hsa_geo).add_to(m)
|
| 286 |
+
|
| 287 |
+
# Filter businesses by selected type
|
| 288 |
+
filtered_df = df_md_final1
|
| 289 |
+
if business_filter != "All":
|
| 290 |
+
filtered_df = df_md_final1[df_md_final1['business_type'] == business_filter]
|
| 291 |
+
|
| 292 |
+
# Define marker colors based on business type
|
| 293 |
+
def get_marker_color(business_type):
|
| 294 |
+
colors = {
|
| 295 |
+
"Autozone": "lightblue",
|
| 296 |
+
"Napa Auto Parts": "lightgreen",
|
| 297 |
+
"O'Reilly Auto Parts": "orange",
|
| 298 |
+
"Advance Auto Parts": "yellow",
|
| 299 |
+
"Car Dealership": "red",
|
| 300 |
+
"Other Auto Repair Shop": "purple"
|
| 301 |
+
}
|
| 302 |
+
return colors.get(business_type, "blue")
|
| 303 |
+
|
| 304 |
+
for _, row in filtered_df.iterrows():
|
| 305 |
+
folium.Marker(
|
| 306 |
+
location=[row['md_y'], row['md_x']],
|
| 307 |
+
popup=row['name'],
|
| 308 |
+
icon=folium.Icon(color=get_marker_color(row['business_type']))
|
| 309 |
+
).add_to(m)
|
| 310 |
+
|
| 311 |
+
# Add the legend to the map
|
| 312 |
+
legend_html = '''
|
| 313 |
+
<div style="position: fixed;
|
| 314 |
+
bottom: 50px; left: 50px; width: 300px; height: 210px;
|
| 315 |
+
background-color: white; z-index:9999; font-size:14px;
|
| 316 |
+
border:2px solid grey;
|
| 317 |
+
padding: 10px;">
|
| 318 |
+
<b>Business Type</b><br>
|
| 319 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightblue"></i> Autozone<br>
|
| 320 |
+
<i class="fa fa-map-marker fa-2x" style="color:lightgreen"></i> Napa Auto Parts<br>
|
| 321 |
+
<i class="fa fa-map-marker fa-2x" style="color:orange"></i> O'Reilly Auto Parts<br>
|
| 322 |
+
<i class="fa fa-map-marker fa-2x" style="color:yellow"></i> Advance Auto Parts<br>
|
| 323 |
+
<i class="fa fa-map-marker fa-2x" style="color:red"></i> Car Dealership<br>
|
| 324 |
+
<i class="fa fa-map-marker fa-2x" style="color:purple"></i> Other Auto Repair Shop<br>
|
| 325 |
+
</div>
|
| 326 |
+
'''
|
| 327 |
+
m.get_root().html.add_child(Element(legend_html))
|
| 328 |
+
|
| 329 |
+
return m._repr_html_()
|
| 330 |
+
|
| 331 |
+
# Function to create a Folium map with HRR boundaries and auto business markers
|
| 332 |
+
def create_hrr_map_filtered(business_filter="All"):
|
| 333 |
+
m = folium.Map(location=[35.8601, -86.6602], zoom_start=8)
|
| 334 |
+
|
| 335 |
+
# Add HRR boundaries
|
| 336 |
+
folium.GeoJson(hrr_geo).add_to(m)
|
| 337 |
+
|
| 338 |
+
# Filter businesses by selected type
|
| 339 |
+
filtered_df = df_md_final1
|
| 340 |
+
if business_filter != "All":
|
| 341 |
+
filtered_df = df_md_final1[df_md_final1['business_type'] == business_filter]
|
| 342 |
|
| 343 |
# Define marker colors based on business type
|
| 344 |
def get_marker_color(business_type):
|
|
|
|
| 393 |
datatype=["str", "str", "str", "str", "str"],
|
| 394 |
value=[
|
| 395 |
["AutoZone", "257 Wears Valley Rd", "Pigeon Forge", "Tennessee", "37863"],
|
| 396 |
+
["Sterling Auto", "2064 Wilma Rudolph Blvd", "Clarksville", "Tennessee", "37040"],
|
| 397 |
+
["AutoZone", "257 Wears Valley Rd", "Pigeon Forge", "Tennessee", "37863"],
|
| 398 |
+
["Sterling Auto", "2064 Wilma Rudolph Blvd", "Clarksville", "Tennessee", "37040"],
|
| 399 |
+
["Advance Auto Parts", "2124 N Highland Ave", "Jackson", "Tennessee", "38305"],
|
| 400 |
+
["FRIENDSHIP HYUNDAI OF BRISTOL", "1841 Volunteer Pkwy", "Bristol", "Tennessee", "37620"],
|
| 401 |
+
["Advance Auto Parts", "45 Main St", "Savannah", "Tennessee", "38372"],
|
| 402 |
+
["O'Reilly Auto Parts", "493 Craighead St", "Nashville", "Tennessee", "37204"],
|
| 403 |
+
["O'Reilly Auto Parts", "864 Highway 51 N", "Covington", "Tennessee", "38019"],
|
| 404 |
+
["NAPA Auto Parts", "711 Murfreesboro Pike", "Nashville", "Tennessee", "37210"],
|
| 405 |
+
["Goodyear Auto Service Centers", "5407 Highway 153", "Hixson", "Tennessee", "37343"],
|
| 406 |
+
["NAPA Auto Parts", "100 Center St", "Johnson City", "Tennessee", "37615"],
|
| 407 |
+
["Cadillac,Buick,Chevrolet,GMC", "960 John R Rice Blvd", "Murfreesboro", "Tennessee", "37129"],
|
| 408 |
+
["AutoZone", "9760 Highway 64", "Lakeland", "Tennessee", "38002"],
|
| 409 |
+
["Honda", "1408 Highway 45 Byp", "Jackson", "Tennessee", "38305"],
|
| 410 |
+
["National Tire & Battery (NTB)", "532 Robert Rose Dr", "Murfreesboro", "Tennessee", "37129"],
|
| 411 |
+
["NAPA Auto Parts", "711 Murfreesboro Pike", "Nashville", "Tennessee", "37210"],
|
| 412 |
+
["Advance Auto Parts", "160 W Broadway", "Gallatin", "Tennessee", "37066"],
|
| 413 |
+
["Southern Tire Mart (STM)", "1551 S Wilcox Dr", "Kingsport", "Tennessee", "37660"],
|
| 414 |
+
["Chevrolet", "310 E 20th St", "Chattanooga", "Tennessee", "37408"],
|
| 415 |
+
["O'Reilly Auto Parts", "7534 Oak Ridge Hwy", "Knoxville", "Tennessee", "37931"],
|
| 416 |
+
["Goodyear Auto Service Centers", "971 Eastgate Loop", "Chattanooga", "Tennessee", "37411"],
|
| 417 |
+
["Firestone Complete Auto Care", "15127 Old Hickory Blvd", "Nashville", "Tennessee", "37211"],
|
| 418 |
+
["Christian Brothers Automotive", "10406 Kingston Pike", "Knoxville", "Tennessee", "37922"],
|
| 419 |
+
["Christian Brothers Automotive", "563 E Main St", "Hendersonville", "Tennessee", "37075"],
|
| 420 |
+
["O'Reilly Auto Parts", "101 Village Square Ln", "Mountain City", "Tennessee", "37683"],
|
| 421 |
+
["O'Reilly Auto Parts", "4219 Fort Henry Dr Ste A", "Kingsport", "Tennessee", "37663"],
|
| 422 |
+
["Precision Tune Auto Care", "4710 N Broadway St", "Knoxville", "Tennessee", "37918"],
|
| 423 |
+
["National Tire & Battery (NTB)", "234 Old Hickory Blvd", "Nashville", "Tennessee", "37221"]
|
| 424 |
+
], # Data values
|
| 425 |
+
row_count=27 # Adjusted total number of rows
|
| 426 |
)
|
| 427 |
|
| 428 |
gr.Markdown("Source: Yellowbook")
|
|
|
|
| 431 |
with gr.Tab("Auto repair shops in TN Counties"):
|
| 432 |
business_options = ["All"] + list(df_md_final1['business_type'].unique())
|
| 433 |
business_filter = gr.Dropdown(label="Select Business Type", choices=business_options, value="All")
|
| 434 |
+
map_output_counties = gr.HTML(lambda business_filter: create_map(business_filter=business_filter), inputs=[business_filter])
|
| 435 |
|
| 436 |
with gr.Tab("Auto Repair Shops in TN Zip Codes"):
|
| 437 |
zip_options = ["All"] + list(df_md_final1['zip_code'].unique())
|
| 438 |
zip_filter = gr.Dropdown(label="Select Zip Code", choices=zip_options, value="All")
|
| 439 |
map_output_zip = gr.HTML(lambda zip_filter: create_map(business_filter="All", county_filter=zip_filter), inputs=[zip_filter])
|
| 440 |
|
| 441 |
+
with gr.Tab("ZCTA Map with Auto Businesses"):
|
| 442 |
+
business_options_zcta = ["All"] + list(df_md_final1['business_type'].unique())
|
| 443 |
+
business_filter_zcta = gr.Dropdown(label="Select Business Type", choices=business_options_zcta, value="All")
|
| 444 |
+
zcta_map_output = gr.HTML(lambda business_filter_zcta: create_zcta_map(business_filter=business_filter_zcta), inputs=[business_filter_zcta])
|
| 445 |
+
|
| 446 |
+
with gr.Tab("HSA Map with Auto Businesses"):
|
| 447 |
+
business_options_hsa = ["All"] + list(df_md_final1['business_type'].unique())
|
| 448 |
+
business_filter_hsa = gr.Dropdown(label="Select Business Type", choices=business_options_hsa, value="All")
|
| 449 |
+
hsa_map_output = gr.HTML(lambda business_filter_hsa: create_hsa_map_filtered(business_filter=business_filter_hsa), inputs=[business_filter_hsa])
|
| 450 |
+
|
| 451 |
+
with gr.Tab("HRR Map with Auto Businesses"):
|
| 452 |
+
business_options_hrr = ["All"] + list(df_md_final1['business_type'].unique())
|
| 453 |
+
business_filter_hrr = gr.Dropdown(label="Select Business Type", choices=business_options_hrr, value="All")
|
| 454 |
+
hrr_map_output = gr.HTML(lambda business_filter_hrr: create_hrr_map_filtered(business_filter=business_filter_hrr), inputs=[business_filter_hrr])
|
| 455 |
+
|
| 456 |
+
app.launch(server_name="0.0.0.0", server_port=7860)
|
data/.DS_Store
CHANGED
|
Binary files a/data/.DS_Store and b/data/.DS_Store differ
|
|
|