File size: 2,308 Bytes
adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 adce761 a5f19b3 b0e8dc8 a5f19b3 b0e8dc8 a5f19b3 adce761 a5f19b3 adce761 |
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 |
import streamlit as st
import folium
import dask.dataframe as dd
from folium.plugins import MarkerCluster
# Top 10 locations for viewing Northern Lights in Iceland
northern_lights_locations = [
{"name": "Reykjavik", "lat": 64.1265, "lon": -21.8174},
{"name": "Akureyri", "lat": 65.6885, "lon": -18.1262},
{"name": "Vik", "lat": 63.4194, "lon": -19.0096},
{"name": "Hofn", "lat": 64.2539, "lon": -15.2082},
{"name": "Husavik", "lat": 66.0449, "lon": -17.3382},
{"name": "Grundarfjordur", "lat": 64.9226, "lon": -23.2543},
{"name": "Egilsstadir", "lat": 65.2669, "lon": -14.3948},
{"name": "Seydisfjordur", "lat": 65.2592, "lon": -14.0101},
{"name": "Isafjordur", "lat": 66.0750, "lon": -23.1266},
{"name": "Kirkjufell", "lat": 64.9426, "lon": -23.3061},
]
# Function to display the map
def display_map(locations, lat, lon):
# Create a folium map centered in Iceland
iceland_map = folium.Map(location=[lat, lon], zoom_start=6)
# Create a marker cluster group
marker_cluster = MarkerCluster().add_to(iceland_map)
# Create a Dask dataframe from the list of locations
dask_df = dd.from_pandas(pd.DataFrame(locations), npartitions=4)
# Add markers for the top 10 locations for viewing Northern Lights
def add_markers(row):
folium.Marker(
location=[row["lat"], row["lon"]],
popup=f"<b>{row['name']}</b>",
).add_to(marker_cluster)
dask_df.map_partitions(lambda df: df.apply(add_markers, axis=1)).compute()
return iceland_map
# Streamlit app
st.title("Northern Lights Map in Iceland")
# User input for latitude and longitude
lat = st.number_input("Enter latitude:", value=64.9631, step=0.0001)
lon = st.number_input("Enter longitude:", value=-19.0208, step=0.0001)
# Display the map
st.write("Northern Lights Viewing Locations in Iceland:")
folium_map = display_map(northern_lights_locations, lat, lon)
st.folium_static(folium_map)
# Cite references
st.write(
"""
References:
- [Folium documentation](https://python-visualization.github.io/folium/)
- [Streamlit documentation](https://docs.streamlit.io/)
- [Dask documentation](https://dask.org/)
- [Top 10 locations](https://www.guidetoiceland.is/best-of-iceland/top-10-places-to-see-the-northern-lights)
"""
)
|