Spaces:
Build error
Build error
import streamlit as st | |
import pandas as pd | |
import pydeck as pdk | |
def show_pydeck_scatterplot(data_url): | |
# create a container for the map and controls | |
container = st.container() | |
# load the data | |
data = pd.read_csv(data_url, usecols=['latitude', 'longitude', 'time']) | |
# create the scatter plot layer | |
scatter_layer = pdk.Layer( | |
'ScatterplotLayer', | |
data=data, | |
get_position='[longitude, latitude]', | |
get_color='[200, 30, time / 100]', | |
get_radius=100, | |
pickable=True, | |
) | |
# create the PyDeck view | |
view = pdk.ViewState(latitude=data['latitude'].mean(), | |
longitude=data['longitude'].mean(), | |
zoom=10, | |
pitch=50) | |
# create the PyDeck map | |
map = pdk.Deck(layers=[scatter_layer], initial_view_state=view) | |
# add the PyDeck map to the container | |
with container: | |
st.pydeck_chart(map) | |
# example usage | |
data_url = 'https://data.cityofnewyork.us/api/views/7x9x-zpz6/rows.csv?accessType=DOWNLOAD' | |
show_pydeck_scatterplot(data_url) | |