import geopandas
import pandas as pd
import matplotlib.pyplot as plt
import streamlit as st
import folium
from streamlit_folium import st_folium
= geopandas.read_file("https://files.catbox.moe/atzk26.gpkg")
gp_list_gdf_sw
# Filter out instances with no geometry
= gp_list_gdf_sw[~gp_list_gdf_sw['geometry'].is_empty]
gp_list_gdf_sw
# Create a geometry list from the GeoDataFrame
= [[point.xy[1][0], point.xy[0][0]] for point in gp_list_gdf_sw.geometry]
geo_df_list
= folium.Map(
gp_map_tooltip =[50.7, -4.2],
location=8,
zoom_start='openstreetmap',
tiles
)
for i, coordinates in enumerate(geo_df_list):
= gp_map_tooltip.add_child(
gp_map_tooltip
folium.Marker(=coordinates,
location=gp_list_gdf_sw['name'].values[i],
tooltip=folium.Icon(icon="user-md", prefix='fa', color="black")
icon
)
)
st_folium(gp_map_tooltip)
"gp_map_devon.html")
gp_map_tooltip.save(
with open("gp_map_devon.html", "rb") as map_file_html:
st.download_button(='Download This Map as an Interactive HTML file',
label=map_file_html,
data=f'Devon GP Map.html',
file_name='text/html'
mime )
21 Downloading Interactive Maps
21.0.1 Folium
Interactive maps can be created using the Folium package.
Folium maps cannot be displayed in Streamlit by default, but can be imported using the st-folium
custom component.