St.pydeck_chart missing Terrain_layer issue

Hello Streamlit! I am currently planning to build a dashboard (kinda waiting for the new st.beta_setpage_config to come out, especially for the "Dashboard"layout! im so excited about it!)

Anyways, im currently building a real-time dashboard that shares different layers of open data to the public (I will explain the whole project later)

But, I figured out that
st.pydeck_chart does not support Terrain_layer for now,right? it might be wrong. But i just want to ask is it supported yet?

Pydeck terrain_layers:
https://deckgl.readthedocs.io/en/latest/gallery/terrain_layer.html

Thank you so much Streamlit Team! I reall enjoied this and have recommended you to my friends.

Please let me know if you know about the pydeck layer update issues. much appreciated

Hi @kforris -

Based on your linked example, they pass in their Mapbox key inside the script like the following:

# Import Mapbox API Key from environment
MAPBOX_API_KEY = os.environ["MAPBOX_API_KEY"]

We wrote a brief note about custom Mapbox styles in our docs, but the quick summary is that you need to pass your Mapbox key via the Streamlit configuration file:

Good afternoon, Randy
Thanks for helping me out!

I just tried to set my "MAPBOX_API_KEY" in config.toml file.
besides of that, since I am coding on Pycharm, I set MAPBOX_API_KEY in my Environment Variables too.

But it is still not working on Terrain_layer while other layers are working fine, I will paste some “controlled tests” below.

Top one works fine, but bottom one with Terrain_layer only shows mapbox layer.

Bottom one was expected to look like this: I have tested codes in jupyter notebook.

Again, thank you so much for replying me. I have joined in the waiting list of [Streamlit for Teams]
sincerely wish you all the best!

1 Like

Would you be able to post your code, without your API key (it looks like SURFACE_IMAGE has it appended to it). If you can, I can take a look at it later, or maybe someone else in the community will have an idea.

import pydeck as pdk

TERRAIN_IMAGE = ‘“https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png”’

ELEVATION_DECODER = {“rScaler”: 256, “gScaler”: 1, “bScaler”: 1 / 256, “offset”: -32768}

SURFACE_IMAGE = ‘“https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=[MAPBOX_API_KEY]”’

terrain_layer = pdk.Layer(
“TerrainLayer”, data=None, elevation_decoder=ELEVATION_DECODER, texture=SURFACE_IMAGE, elevation_data=TERRAIN_IMAGE
)

view_state = pdk.ViewState(latitude=46.24, longitude=-122.18, zoom=11.5, bearing=140, pitch=60)

r3= pdk.Deck(terrain_layer, initial_view_state=view_state)
st.pydeck_chart(r3)

Hi Randy, above is the code. the code works on jupyter notebook (just switch st.pydeck_chart into r.to_html().

I might be wrong since im so new to coding, but on Jan. 14th version 0.53.0 Streamlit announced that all pydeck layers were supported, but Terrain_layer was released by Deckgl on March 2020.

https://docs.streamlit.io/en/stable/changelog.html?highlight=pydeck%20#version-0-53-0
https://deck.gl/docs/whats-new#deckgl-v81

I dont know how python library works but that was my guess.

Thank you Randy and Streamlit Community!

If anyone knows the exact reason please let me know.

My guess is that streamlit lib of [Pydeck_layers] is kinda outdate.

Much appreciated!

I’ll try and take a look at this today @kforris, thanks for following-up

1 Like

Thanks for your patience @kforris -

I think fundamentally, this is the same error as the others, where the key is specified in the Python script instead of in the config file. Additionally, I think we’re either not expecting the terrain layer (whether that’s because it came out after we implemented this as you noted), or we’re not expecting a key in terrain layer value.

Either way, I will file this as an issue on GitHub, hopefully our engineers can resolve this quickly.

Best,
Randy

1 Like

Thank you Randy, i will be waiting for releases.

I tested Streamlit 0.66 which just released 3 hours ago, it did not work, but now we know whats the problems are, all I need to do is explore more about Streamlit while waiting for pros to setup improvement.

Sincerely thank you Randy and Streamlit Community!

Sincerely,
Kris.

1 Like

You’re welcome Kris! The pull request for updating the dependencies didn’t make it into yesterday’s 0.66 release, but I would expect it to get merged into the codebase within the next week, which would make it available in streamlit-nightly the next day.