Hi Every ones , need some helps here, I’m still a rookie in this streamlit stuffs so feel free to give some feedback upon my codes. Here is the problems, I create tools using streamlit and Draw plugin, whenever user draw polygon on certain areas, it will create geohash visualizations. I have difficulty to overlay the geohash above drawing layer. Here is my code
import folium
import geopandas as gpd
import json
import numpy as np
import streamlit as st
from polygeohasher import polygeohasher
from shapely.geometry import Polygon
from shapely import wkt
from streamlit_folium import st_folium
from folium.plugins import Draw
from streamlit_folium import st_folium
button = st.number_input('Insert a Geohash number')
number = int(button)
c1, c2 = st.columns(2)
with c1:
m = folium.Map([-6.175300560878783, 106.82701205991948],zoom_start=16)
Draw(export=False).add_to(m)
output = st_folium(m, width=1200, height=800)
geojson_str = json.dumps(output)
geojson_data = gpd.read_file(geojson_str, driver='GeoJSON')
gdf = gpd.GeoDataFrame.from_features(geojson_data)
geohash_gdf = polygeohasher.create_geohash_list(gdf, number,inner=False)
geohash_gdf_list = polygeohasher.geohashes_to_geometry(geohash_gdf,"geohash_list")
gpd_geohash_geom = gpd.GeoDataFrame(geohash_gdf_list, geometry=geohash_gdf_list['geometry'], crs="EPSG:4326")
geojson_geohash = gpd_geohash_geom.to_json()
folium.features.GeoJson(geojson_geohash,
tooltip = folium.GeoJsonTooltip(fields = ['geohash_list']),
style_function = lambda x:{
'color': 'blue'
}).add_to(m)
with c2:
st_folium(m, width=1200, height=800)
csv=gpd_geohash_geom.to_csv()
st.download_button(
label="Download data as CSV",
data=csv,
file_name='geohash_file.csv',
mime='text/csv',
)
Please help. Thanks