Hello,
I’m trying to put a map with box selection using Google Colab. I get another example and replied with sucess. But, when I do with my data, I gine the following message.
Can you please paste a small reproducible example script which shows this behavior?
Dear,
Sure. Thanks
!pip install -q streamlit
!pip install folium -q
!pip install streamlit_folium -q
%%writefile app.py
import pandas as pd
import streamlit as st
import folium
from streamlit_folium import st_folium
from streamlit_folium import folium_static
st.set_page_config(layout=“wide”)
choropleth = folium.Choropleth(
geo_data=‘/content/drive/MyDrive/stream.geojson’
)
json1 = f"/content/drive/MyDrive/stream.geojson"
m = folium.Map(location=[23.47, 77.94], tiles=‘CartoDB positron’,name=“Light Map”,
zoom_start=5,
attr=‘My Data Attribution’)
india_covid_data = pd.read_csv(‘/content/Pasta1.csv’,sep=‘;’)
choice = [‘segunda_m1’,‘segunda_m2’,‘terca_m1’,‘terca_m2’,‘sexta_m1’,‘sexta_m2’]
choice_selected = st.selectbox(“Select Choice “, choice)
folium.Choropleth(
geo_data=json1,
name=“choropleth”,
data=india_covid_data,
columns=[“FID”, choice_selected],
key_on=“features.properties.FID”,
fill_color=“YlOrRd”,
fill_opacity=0.7,
line_opacity=.1,
legend_name=choice_selected+”(%)”,
).add_to(m)
folium.features.GeoJson(‘/content/drive/MyDrive/stream.geojson’, name=“LSOA Code”,
popup=folium.features.GeoJsonPopup(fields=[‘FID’])).add_to(m)
folium_static(m, width=1600, height=950)
!streamlit run app.py & npx localtunnel --port 8501
Not sure why that’s happening – my best guess is that it’s having an issue accessing "/content/drive/MyDrive/stream.geojson"
– can you double check that that file exists?
You could do something like
from pathlib import Path
st.write(Path("/content/drive/MyDrive/stream.geojson").exists())