streamlit-folium icon indicating copy to clipboard operation
streamlit-folium copied to clipboard

Keep legend from geopandas folium object

Open raybellwaves opened this issue 1 year ago • 3 comments
trafficstars

Thanks for this package!

I'm trying to use this package to show a map which is from https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html

For unknown reason the legend isn't passed through.

notebook:

import geodatasets as gds
import geopandas as gpd
gdf = gpd.read_file(gds.data["naturalearth"]["land"]["url"])
gdf.explore(column="min_zoom")

Screenshot 2024-05-30 at 9 23 12 PM

streamlit:

from streamlit_folium import st_folium
import geodatasets as gds
import geopandas as gpd
gdf = gpd.read_file(gds.data["naturalearth"]["land"]["url"])
m = gdf.explore(column="min_zoom")
st_folium(m)

Screenshot 2024-05-30 at 9 25 03 PM

raybellwaves avatar May 31 '24 01:05 raybellwaves

I have the same problem as you!

ShootingStarD avatar Jun 07 '24 08:06 ShootingStarD

Is the legend not passed through or is the map the wrong size?

randyzwitch avatar Jun 17 '24 13:06 randyzwitch

Is the legend not passed through or is the map the wrong size?

I think not passed through. I'll try and create a MCVE when I get some time

raybellwaves avatar Jun 17 '24 13:06 raybellwaves

Works for me @raybellwaves

Screenshot 2024-10-30 at 7 04 38 PM
(streamlit_clean) randyzwitch@Mac anna_debug % conda list
# packages in environment at /Users/randyzwitch/miniconda3/envs/streamlit_clean:
#
# Name                    Version                   Build  Channel
altair                    5.4.1              pyhd8ed1ab_1    conda-forge
appnope                   0.1.4              pyhd8ed1ab_0    conda-forge
arrow-cpp                 16.1.0               hbc20fb2_0  
asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
attrs                     24.2.0             pyh71513ae_0    conda-forge
aws-c-auth                0.6.21               h284e69b_0    conda-forge
aws-c-cal                 0.5.20               h7a1267a_3    conda-forge
aws-c-common              0.8.5                h1a8c8d9_0    conda-forge
aws-c-compression         0.2.16               ha56e2a8_0    conda-forge
aws-c-event-stream        0.2.15              h5f184b6_11    conda-forge
aws-c-http                0.6.27               hb329ca4_3    conda-forge
aws-c-io                  0.13.11              h2ec9475_2    conda-forge
aws-c-mqtt                0.7.13               h5377834_9    conda-forge
aws-c-s3                  0.2.1                hbdbf862_0    conda-forge
aws-c-sdkutils            0.1.7                ha56e2a8_0    conda-forge
aws-checksums             0.1.13               ha56e2a8_5    conda-forge
aws-crt-cpp               0.18.16              h14806b3_2    conda-forge
aws-sdk-cpp               1.10.55              h313beb8_0  
blas                      2.125                  openblas    conda-forge
blas-devel                3.9.0           25_osxarm64_openblas    conda-forge
blinker                   1.8.2              pyhd8ed1ab_0    conda-forge
boost-cpp                 1.78.0               hb428463_0    conda-forge
bottleneck                1.3.7           py312ha86b861_0  
branca                    0.7.2              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h1a8c8d9_9    conda-forge
brotli-bin                1.0.9                h1a8c8d9_9    conda-forge
brotli-python             1.0.9           py312h313beb8_8  
bzip2                     1.0.8                h80987f9_6  
c-ares                    1.34.2               h7ab814d_0    conda-forge
ca-certificates           2024.9.24            hca03da5_0  
cachetools                5.5.0              pyhd8ed1ab_0    conda-forge
certifi                   2024.8.30          pyhd8ed1ab_0    conda-forge
cffi                      1.17.1          py312h3eb5a62_0  
charset-normalizer        3.4.0              pyhd8ed1ab_0    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_0    conda-forge
contourpy                 1.2.0           py312h48ca7d4_0  
cycler                    0.12.1             pyhd8ed1ab_0    conda-forge
debugpy                   1.6.7           py312h313beb8_0  
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
exceptiongroup            1.2.2              pyhd8ed1ab_0    conda-forge
executing                 2.1.0              pyhd8ed1ab_0    conda-forge
expat                     2.6.3                h313beb8_0  
folium                    0.18.0             pyhd8ed1ab_0    conda-forge
fonttools                 4.54.1          py312ha0ccf2a_1    conda-forge
freetype                  2.10.4               h17b34a0_1    conda-forge
geodatasets               2024.8.0                 pypi_0    pypi
geopandas                 1.0.1                    pypi_0    pypi
gflags                    2.2.2             hc88da5d_1004    conda-forge
gitdb                     4.0.11             pyhd8ed1ab_0    conda-forge
gitpython                 3.1.43             pyhd8ed1ab_0    conda-forge
glog                      0.5.0                h5c6a83d_0    conda-forge
h2                        4.1.0              pyhd8ed1ab_0    conda-forge
hpack                     4.0.0              pyh9f0ad1d_0    conda-forge
hyperframe                6.0.1              pyhd8ed1ab_0    conda-forge
icu                       70.1                 h6b3803e_0    conda-forge
idna                      3.10               pyhd8ed1ab_0    conda-forge
importlib-metadata        7.2.1              pyha770c72_0    conda-forge
importlib_resources       6.4.5              pyhd8ed1ab_0    conda-forge
ipykernel                 6.29.5             pyh57ce528_0    conda-forge
ipython                   8.29.0             pyh707e725_0    conda-forge
ipywidgets                8.1.5              pyhd8ed1ab_0    conda-forge
jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.4              pyhd8ed1ab_0    conda-forge
joblib                    1.4.2              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h1a8c8d9_3    conda-forge
jsonschema                4.23.0             pyhd8ed1ab_0    conda-forge
jsonschema-specifications 2024.10.1          pyhd8ed1ab_0    conda-forge
jupyter_client            8.6.3              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2              pyh31011fe_1    conda-forge
jupyterlab_widgets        3.0.13             pyhd8ed1ab_0    conda-forge
kiwisolver                1.4.4           py312h313beb8_0  
krb5                      1.20.1               h69eda48_0    conda-forge
lcms2                     2.15                 h481adae_0    conda-forge
lerc                      3.0                  hbdafb3b_0    conda-forge
libabseil                 20240116.2      cxx17_h313beb8_0  
libblas                   3.9.0           25_osxarm64_openblas    conda-forge
libbrotlicommon           1.0.9                h1a8c8d9_9    conda-forge
libbrotlidec              1.0.9                h1a8c8d9_9    conda-forge
libbrotlienc              1.0.9                h1a8c8d9_9    conda-forge
libcblas                  3.9.0           25_osxarm64_openblas    conda-forge
libcurl                   8.9.1                h3e2b118_0  
libcxx                    14.0.6               h848a8c0_0  
libdeflate                1.17                 h1a8c8d9_0    conda-forge
libedit                   3.1.20191231         hc8eb9b7_2    conda-forge
libev                     4.33                 h93a5062_2    conda-forge
libevent                  2.1.12               h2757513_1    conda-forge
libexpat                  2.6.3                hf9b8971_0    conda-forge
libffi                    3.4.4                hca03da5_1  
libgfortran               5.0.0           13_2_0_hd922786_3    conda-forge
libgfortran5              13.2.0               hf226fd6_3    conda-forge
libgrpc                   1.62.2               h62f6fdd_0  
liblapack                 3.9.0           25_osxarm64_openblas    conda-forge
liblapacke                3.9.0           25_osxarm64_openblas    conda-forge
libnghttp2                1.57.0               h62f6fdd_0  
libopenblas               0.3.28          openmp_h517c56d_0    conda-forge
libpng                    1.6.37               hf7e6567_2    conda-forge
libprotobuf               4.25.3               h514c7bf_0  
libsodium                 1.0.18               h27ca646_1    conda-forge
libsqlite                 3.46.0               hfb93653_0    conda-forge
libssh2                   1.10.0               h7a5bd25_2    conda-forge
libthrift                 0.15.0               h73c2103_2  
libtiff                   4.5.1                h313beb8_0  
libwebp-base              1.4.0                h93a5062_0    conda-forge
libzlib                   1.2.13               hfb2fe0b_6    conda-forge
llvm-openmp               19.1.2               hb52a8e5_0    conda-forge
lz4-c                     1.9.4                hb7217d7_0    conda-forge
mapclassify               2.8.1              pyhd8ed1ab_0    conda-forge
markdown-it-py            3.0.0              pyhd8ed1ab_0    conda-forge
markupsafe                3.0.2              pyhe1237c8_0    conda-forge
matplotlib                3.9.2           py312h1f38498_1    conda-forge
matplotlib-base           3.9.2           py312h2df2da3_0  
matplotlib-inline         0.1.7              pyhd8ed1ab_0    conda-forge
mdurl                     0.1.2              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
narwhals                  1.12.1             pyhd8ed1ab_0    conda-forge
ncurses                   6.4                  h313beb8_0  
nest-asyncio              1.6.0              pyhd8ed1ab_0    conda-forge
networkx                  3.4.2              pyhd8ed1ab_1    conda-forge
numexpr                   2.10.1          py312h5d9532f_0  
numpy                     1.26.4          py312h7f4fdc5_0  
numpy-base                1.26.4          py312he047099_0  
openblas                  0.3.28          openmp_h1f0b1b2_0    conda-forge
openjpeg                  2.3.0                h7a6adac_2  
openssl                   3.3.2                h8359307_0    conda-forge
orc                       2.0.1                h937ddfc_0  
packaging                 24.1               pyhd8ed1ab_0    conda-forge
pandas                    2.2.2           py312hd77ebd4_0  
parso                     0.8.4              pyhd8ed1ab_0    conda-forge
pexpect                   4.9.0              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    10.4.0          py312h80987f9_0  
pip                       24.2            py312hca03da5_0  
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_1    conda-forge
platformdirs              4.3.6              pyhd8ed1ab_0    conda-forge
pooch                     1.8.2                    pypi_0    pypi
prompt-toolkit            3.0.48             pyha770c72_0    conda-forge
protobuf                  4.25.3          py312h8472c4a_0  
psutil                    5.9.0           py312h80987f9_0  
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.3              pyhd8ed1ab_0    conda-forge
pyarrow                   16.1.0          py312hd77ebd4_0  
pybind11-abi              5                    hd3eb1b0_0  
pycparser                 2.22               pyhd8ed1ab_0    conda-forge
pydeck                    0.8.0              pyhd8ed1ab_0    conda-forge
pygments                  2.18.0             pyhd8ed1ab_0    conda-forge
pyogrio                   0.10.0                   pypi_0    pypi
pyparsing                 3.2.0              pyhd8ed1ab_1    conda-forge
pyproj                    3.7.0                    pypi_0    pypi
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.12.2          hdf0ec26_0_cpython    conda-forge
python-dateutil           2.9.0              pyhd8ed1ab_0    conda-forge
python-tzdata             2024.2             pyhd8ed1ab_0    conda-forge
python_abi                3.12                    5_cp312    conda-forge
pytz                      2024.2             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0.2           py312h80987f9_0  
pyzmq                     25.1.2          py312h313beb8_0  
re2                       2022.04.01           h6b3803e_0    conda-forge
readline                  8.2                  h1a28f6b_0  
referencing               0.35.1             pyhd8ed1ab_0    conda-forge
requests                  2.32.3             pyhd8ed1ab_0    conda-forge
rich                      13.9.3             pyhd8ed1ab_0    conda-forge
rpds-py                   0.10.6          py312hf0e4da2_0  
scikit-learn              1.5.1           py312hd77ebd4_0  
scipy                     1.13.1          py312ha409365_0  
setuptools                75.1.0          py312hca03da5_0  
shapely                   2.0.6                    pypi_0    pypi
six                       1.16.0             pyh6c4a22f_0    conda-forge
smmap                     5.0.0              pyhd8ed1ab_0    conda-forge
snappy                    1.1.10               h17c5cce_0    conda-forge
sqlite                    3.45.3               h80987f9_0  
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
streamlit                 1.39.0             pyhd8ed1ab_0    conda-forge
streamlit-folium          0.23.1             pyhd8ed1ab_0    conda-forge
tenacity                  9.0.0              pyhd8ed1ab_0    conda-forge
threadpoolctl             3.5.0              pyhc1e730c_0    conda-forge
tk                        8.6.14               h6ba3021_0  
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tornado                   6.4.1           py312h80987f9_0  
traitlets                 5.14.3             pyhd8ed1ab_0    conda-forge
typing-extensions         4.12.2               hd8ed1ab_0    conda-forge
typing_extensions         4.12.2             pyha770c72_0    conda-forge
tzdata                    2024b                h04d1e81_0  
tzlocal                   3.0                pyhd8ed1ab_0    conda-forge
unicodedata2              15.1.0          py312h0bf5046_1    conda-forge
urllib3                   2.2.3              pyhd8ed1ab_0    conda-forge
utf8proc                  2.6.1                h80987f9_1  
validators                0.34.0             pyhd8ed1ab_0    conda-forge
watchdog                  4.0.1           py312h80987f9_0  
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
wheel                     0.44.0          py312hca03da5_0  
widgetsnbextension        4.0.13             pyhd8ed1ab_0    conda-forge
xyzservices               2024.9.0           pyhd8ed1ab_0    conda-forge
xz                        5.4.6                h80987f9_1  
yaml                      0.2.5                h3422bc3_2    conda-forge
zeromq                    4.3.5                h313beb8_0  
zipp                      3.20.2             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               hfb2fe0b_6    conda-forge
zstandard                 0.23.0          py312h1a4646a_0  
zstd                      1.5.6                hfb09047_0  

randyzwitch avatar Oct 30 '24 23:10 randyzwitch