|
import streamlit as st |
|
import folium |
|
import dask.dataframe as dd |
|
from folium.plugins import MarkerCluster |
|
|
|
|
|
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}, |
|
] |
|
|
|
|
|
def display_map(locations, lat, lon): |
|
|
|
iceland_map = folium.Map(location=[lat, lon], zoom_start=6) |
|
|
|
|
|
marker_cluster = MarkerCluster().add_to(iceland_map) |
|
|
|
|
|
dask_df = dd.from_pandas(pd.DataFrame(locations), npartitions=4) |
|
|
|
|
|
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 |
|
|
|
|
|
st.title("Northern Lights Map in Iceland") |
|
|
|
|
|
lat = st.number_input("Enter latitude:", value=64.9631, step=0.0001) |
|
lon = st.number_input("Enter longitude:", value=-19.0208, step=0.0001) |
|
|
|
|
|
st.write("Northern Lights Viewing Locations in Iceland:") |
|
folium_map = display_map(northern_lights_locations, lat, lon) |
|
st.folium_static(folium_map) |
|
|
|
|
|
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) |
|
""" |
|
) |
|
|