Pydeck map not displaying data layer

I cannot get streamlit/pydeck to display map layer data. When I try to print the input table and objects it all seems OK but the map loads empty. Tried tons possible scale/range combinations but hit the wall of what else could be wrong. It is expected to show a thic bar on a country level, thus the radius size. Any thoughts of what can be wrong?

Part of the csv file I am loading:

country,radku,lat,lon
ALB,1,41,20
ARE,126,24,54
ARG,24,-34,-64
AUS,103,-27,133
AUT,1217,47.3333,13.3333
AZE,2,40.5,47.5
BEL,582,50.8333,4

Data loading (loads fine with all the data, column names…):

@st.experimental_singleton
def load_data():
    data = pd.read_csv(
        "2022-lat-lon-summary.csv.gz",
        nrows=75,  # 64626 number of lines to read
        names=[
            "ctry",
            "lines",
            "lat",
            "lon"
        ],  # specify names directly since they don't change
        skiprows=1,  # don't read header since names specified directly
        usecols=[0, 1, 2, 3],  
    )
    return data

Display function (only displays map, no layer):

def map(data, lat, lon, zoom):
    st.write(
        pdk.Deck(
            map_style="mapbox://styles/mapbox/light-v11",
            initial_view_state={
                "latitude": lat,
                "longitude": lon,
                "zoom": zoom,
                "pitch": 50,
            },
            layers=[
                pdk.Layer(
                    "HexagonLayer",
                    data=data,
                    get_position=["lon", "lat"],
                    auto_highlight = True,
                    radius=70000,
                    elevation_scale=1,
                    elevation_range=[0, 2000], #reduced from 20000 as max in data is 16k for forum post
                    pickable=True,
                    extruded=True,
                    getElevationValue =["lines"]
                )
            ],
        )
    )

Ok so I figured that I am using Hexagonlayer incorrectly and should be using ColumnLayer for the data set I am trying to display. So the layer definition is

   layer=pdk.Layer(
                "ColumnLayer",
                data=data,
                get_position='[lon, lat]',
                getElevation ='lines',
                auto_highlight = True,
                radius = 100,
                pickable = True,
                extruded = True,
                radius_Units = String("pixels")
            )     

But unfortunately still no layer gets displayed, no errors in console. :frowning: Tried various syntaxes, pulled out many hairs by now, any hints appreciated.

1 Like

OK another update by me.
It is 100% get_position not correctly parsing the lon/lan data. Everything else is working including tooltips but displaying all the columns stacked on each other in position 0,0 as per the screenshot below.

current code:

    layer=pdk.Layer(
                'ColumnLayer',
                data=data,
                get_position =["lon", "lat"],
                get_elevation ="radku",
                auto_highlight = True,
                radius = 100000,
                elevation_scale = 1000,
                pickable = True,
                extruded = True,
                get_Fill_Color = [48, 128, 255, 255],
            )     
    tooltip = {
    "html": "<b>{radku}</b> lines shipped in 2022 to <b>{country}</b> {lon} , {lat}",
    "style": {"background": "grey", "color": "white", "font-family": '"Helvetica Neue", Arial', "z-index": "10000"}}

Question remains - what is going on, why is it wrong?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.