I am trying to plot some latitude/longitude locations as points on a map using pydeck_chart but it’s not working. There are no errors. The map shows up fine, but the points aren’t plotted.
This is my code:
import pandas as pd import streamlit as st import pydeck as pdk df = pd.DataFrame(data=[[44.0578, -80.3267], [44.0596, -80.3296], [44.0613, -80.3324], [44.0625, -80.3346]], columns=['latitude', 'longitude']) view_state = pdk.ViewState(latitude=44.057, longitude=-80.325, zoom=10) layer = pdk.Layer( 'ScatterplotLayer', data=df, get_position=['latitude', 'longitude'], get_radius=50, pickable=True, filled=True ) st.pydeck_chart(pdk.Deck( map_style="mapbox://styles/mapbox/light-v9", layers=[layer], initial_view_state=view_state, ))
Using streamlit version 0.82.0
What could be wrong?
EDIT: I figured it out. The order of strings in get_position matters: must place longitude before latitude.
On that note, I’m wondering why is it like that? If they’re strings in a list, can we just extract the corresponding column from the passed in data by string value?