hi all !
This is my first message here, so i want to thank you for your wonderful work ! Streamlit is so nice and friendly, great !
I am facing some issues trying to reproduce the pydeck HexagonLayer demo. when i use .csv data from url all works fine and it’s look like this
But if, data used for pydeck, are dataframe, local .csv or list of dict, then the map is super slow, not usable… While it is working fine in jupyter.
I am using:
- streamlit 0.69
- python 3.8.6
- Ubuntu 18.04.5
- Firefox 82.0.2
- Pipenv
2 more things !
- If i use list of dict as data, then the cache seems not working…
- Map totally freezing with streamlit 0.70
Maybe i’am doing something wrong ?
Thank you in advance !!
Dorian
App script:
"""
HexagonLayer
==============
Personal injury road accidents in GB from 1979.
The layer aggregates data within the boundary of each hexagon cell.
This example is adapted from the deck.gl documentation.
"""
import streamlit as st
import pandas as pd
import pydeck as pdk
#LOADING DATA
DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv"
@st.cache
def load_data():
"""Choose here your data format"""
data = pd.read_csv(DATA_URL).dropna() ## super slow if used
# data.to_csv('./data.csv',index=False)
# data = pd.read_csv('./data.csv') ## super slow if used
# data = data.to_dict('records') ## super slow if used
return data
# LAYER
def map(data):
view_state = pdk.ViewState(
longitude=-1.415,
latitude=52.2323,
zoom=6,
min_zoom=5,
max_zoom=15,
pitch=40.5,
bearing=-27.36,
)
layer = pdk.Layer(
"HexagonLayer",
data,
get_position=["lng", "lat"],
auto_highlight=True,
elevation_scale=height,
pickable=True,
elevation_range=[0, 3000],
extruded=True,
coverage=1,
radius=radius,
opacity=opacity
)
st.pydeck_chart(pdk.Deck(
layers=[layer],
initial_view_state=view_state,
tooltip=True
)
)
# SIDEBARs
radius = st.sidebar.slider("Diameter of ⬡ (meters) ", 100, 20000, 10000, 100) // 2
height = st.sidebar.slider("Height of ⬡",1, 200, 100, 10)
opacity = st.sidebar.slider('Opacity', 0.01, 1.0, 1.0, 0.01)
# RENDER
data = load_data()
if st.checkbox('Display data ?'):
data
map(DATA_URL)
# map(data) ## Super slow