Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import folium
|
3 |
+
from streamlit_folium import folium_static
|
4 |
+
|
5 |
+
# Define hospital data
|
6 |
+
hospitals = [
|
7 |
+
{'name': 'Ohio State University', 'state': 'OH', 'lat': 40.0057, 'long': -83.0287},
|
8 |
+
{'name': 'University of Maryland--College Park', 'state': 'MD', 'lat': 38.9869, 'long': -76.9426},
|
9 |
+
{'name': 'University of Alabama--Birmingham', 'state': 'AL', 'lat': 33.5057, 'long': -86.8064},
|
10 |
+
{'name': 'University of California--San Francisco', 'state': 'CA', 'lat': 37.7631, 'long': -122.4572},
|
11 |
+
{'name': 'University of Colorado--Denver', 'state': 'CO', 'lat': 39.7433, 'long': -105.0062},
|
12 |
+
{'name': 'University of Florida', 'state': 'FL', 'lat': 29.6445, 'long': -82.3549},
|
13 |
+
{'name': 'Duke University', 'state': 'NC', 'lat': 36.0014, 'long': -78.9382},
|
14 |
+
{'name': 'Northwestern University (Feinberg)', 'state': 'IL', 'lat': 41.8962, 'long': -87.6214},
|
15 |
+
{'name': 'Stanford University', 'state': 'CA', 'lat': 37.4275, 'long': -122.1697},
|
16 |
+
{'name': 'Columbia University', 'state': 'NY', 'lat': 40.8075, 'long': -73.9626},
|
17 |
+
{'name': 'University of North Carolina--Chapel Hill', 'state': 'NC', 'lat': 35.9049, 'long': -79.0469},
|
18 |
+
{'name': 'University of Southern California (Keck)', 'state': 'CA', 'lat': 34.0208, 'long': -118.2858},
|
19 |
+
{'name': 'University of Utah', 'state': 'UT', 'lat': 40.7644, 'long': -111.8421},
|
20 |
+
{'name': 'University of Wisconsin--Madison', 'state': 'WI', 'lat': 43.0768, 'long': -89.4105},
|
21 |
+
{'name': 'University of Texas Southwestern Medical Center--Dallas', 'state': 'TX', 'lat': 32.8124, 'long': -96.8420},
|
22 |
+
{'name': 'University of California--Los Angeles (Geffen)', 'state': 'CA', 'lat': 34.0689, 'long': -118.4439},
|
23 |
+
{'name': 'University of Iowa (Carver)', 'state': 'IA', 'lat': 41.6599, 'long': -91.5363},
|
24 |
+
{'name': 'University of Michigan--Ann Arbor', 'state': 'MI', 'lat': 42.2808, 'long': -83.7430},
|
25 |
+
{'name': 'University of Wisconsin--Madison', 'state': 'WI', 'lat': 43.0768, 'long': -89.4105},
|
26 |
+
{'name': 'University of North Carolina--Chapel Hill', 'state': 'NC', 'lat': 35.9049, 'long': -79.0469},
|
27 |
+
]
|
28 |
+
|
29 |
+
# Create
|
30 |
+
# a map centered on the US
|
31 |
+
m = folium.Map(location=[37.0902, -95.7129], zoom_start=4)
|
32 |
+
|
33 |
+
# Define a function to add a marker for a hospital
|
34 |
+
def add_marker(hospital):
|
35 |
+
popup_text = f"{hospital['name']}, {hospital['state']}"
|
36 |
+
folium.Marker(
|
37 |
+
location=[hospital['lat'], hospital['long']],
|
38 |
+
popup=popup_text
|
39 |
+
).add_to(m)
|
40 |
+
|
41 |
+
# Add markers for each hospital
|
42 |
+
for hospital in hospitals:
|
43 |
+
add_marker(hospital)
|
44 |
+
|
45 |
+
# Display the map in Streamlit
|
46 |
+
folium_static(m)
|
47 |
+
|
48 |
+
|
49 |
+
# Note that you will need to have the `streamlit`, `folium`, and `streamlit-folium` packages installed in order to run this code. You can install them using `pip`! Try PyPi
|