Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Northern.Lights.Map.Streamlit.Folium - write a streamlit python program that uses functions and user interface elements of a textbox, a dial, a four direction button array for up down left right and display a folium map with the data in python list dictionaries with these values: Aurora Spottings, Notifications on Nerthern Lights, Northern lights map location cities and countries for Iceland on a map written with folium for latitude and longitude of top ten places to view Northern Lights. Cite References as urls.
|
2 |
+
import streamlit as st
|
3 |
+
import folium
|
4 |
+
from folium import Marker
|
5 |
+
from streamlit_folium import folium_static
|
6 |
+
|
7 |
+
# Top 10 locations for viewing Northern Lights in Iceland
|
8 |
+
northern_lights_locations = [
|
9 |
+
{"name": "Reykjavik", "lat": 64.1265, "lon": -21.8174},
|
10 |
+
{"name": "Akureyri", "lat": 65.6885, "lon": -18.1262},
|
11 |
+
{"name": "Vik", "lat": 63.4194, "lon": -19.0096},
|
12 |
+
{"name": "Hofn", "lat": 64.2539, "lon": -15.2082},
|
13 |
+
{"name": "Husavik", "lat": 66.0449, "lon": -17.3382},
|
14 |
+
{"name": "Grundarfjordur", "lat": 64.9226, "lon": -23.2543},
|
15 |
+
{"name": "Egilsstadir", "lat": 65.2669, "lon": -14.3948},
|
16 |
+
{"name": "Seydisfjordur", "lat": 65.2592, "lon": -14.0101},
|
17 |
+
{"name": "Isafjordur", "lat": 66.0750, "lon": -23.1266},
|
18 |
+
{"name": "Kirkjufell", "lat": 64.9426, "lon": -23.3061},
|
19 |
+
]
|
20 |
+
|
21 |
+
def display_map(locations):
|
22 |
+
# Create a folium map centered in Iceland
|
23 |
+
iceland_map = folium.Map(location=[64.9631, -19.0208], zoom_start=6)
|
24 |
+
|
25 |
+
# Add markers for the top 10 locations for viewing Northern Lights
|
26 |
+
for location in locations:
|
27 |
+
Marker(
|
28 |
+
[location["lat"], location["lon"]],
|
29 |
+
popup=f"<b>{location['name']}</b>",
|
30 |
+
).add_to(iceland_map)
|
31 |
+
|
32 |
+
return iceland_map
|
33 |
+
|
34 |
+
# Streamlit app
|
35 |
+
st.title("Top 10 Locations to View Northern Lights in Iceland")
|
36 |
+
|
37 |
+
# Textbox
|
38 |
+
user_text = st.text_input("Enter your text:")
|
39 |
+
|
40 |
+
# Dial
|
41 |
+
dial_value = st.slider("Select a value:", 0, 100)
|
42 |
+
|
43 |
+
# Four-direction button array
|
44 |
+
st.write("Four-direction button array:")
|
45 |
+
col1, col2, col3 = st.columns(3)
|
46 |
+
with col2:
|
47 |
+
st.button("Up")
|
48 |
+
with col1:
|
49 |
+
st.button("Left")
|
50 |
+
with col3:
|
51 |
+
st.button("Right")
|
52 |
+
with col2:
|
53 |
+
st.button("Down")
|
54 |
+
|
55 |
+
# Display Folium map
|
56 |
+
st.write("Top 10 locations for viewing the Northern Lights in Iceland:")
|
57 |
+
folium_map = display_map(northern_lights_locations)
|
58 |
+
folium_static(folium_map)
|
59 |
+
|
60 |
+
# Cite references
|
61 |
+
st.write(
|
62 |
+
"""
|
63 |
+
References:
|
64 |
+
- [Folium documentation](https://python-visualization.github.io/folium/)
|
65 |
+
- [Streamlit documentation](https://docs.streamlit.io/)
|
66 |
+
- [Top 10 locations](https://www.guidetoiceland.is/best-of-iceland/top-10-places-to-see-the-northern-lights)
|
67 |
+
"""
|
68 |
+
)
|