How to make pydeck_chart Hexagon layer bar height based on column value

I have a column in my .csv file I want to use to determine the bar height in my pydeck_chart Hexagon layer. So instead of having multiple rows with the same longitude and latitude, each coordinates are in the file just once and there’s a column that’s supposed to determine the height. seems to have a attribute getElevationHeight that’s supposed to work, but I can’t for the life of me figure out how it works through Streamlit and pydeck_chart.

I found a question here with a similar problem, but it’s using deprecated deck_gl_chart: How to make Hexagon Layer height value based, and I couldn’t get it to work anyway…

Here’s my code:

            get_position='[longitude, latitude]',
            get_elevation_value='sensorValue',    # <- Does not work
            elevation_range=[1, 10000],

Here’s a look how my csv file looks like:

I guess this is more of a Pydeck question than Streamlit question but seeing there’s such an active and helpful community I decided to try here! Do you know how to make it work?

Answering myself if anyone is reading this:

ColumnLayer seems to be more what I’m after. A ColumnLayer with similar settings and get_elevation set to the column name seems to do the trick, and provide very similar functionality to HexagonLayer.

It would still be interesting to hear what I’m doing wrong with the HexagonLayer, if anyone has the answer!

You wrote such a nice thing, and then none of us responded :cry:

Have you tried our example from the docs, just to make sure this works at all in your app before customization?

Thanks for the reply!

Yeah, the example works. I think I got the idea of the layer wrong. While HexagonLayer is expecting a separate row for each point and calculates the height of the bar from the number of rows, ColumnLayer is more directed to my case when there is one row per bar, with the height value included in the row.

So maybe I shouldn’t force the poor HexagonLayer to be something it doesn’t want to be. We’re happy together now with ColumnLayer, and I think that’s better for all of us.

1 Like