awacke1's picture
Create app.py
38532d2
raw
history blame
908 Bytes
import streamlit as st
import pandas as pd
import pydeck as pdk
# create a container for the map and controls
container = st.container()
# load the data
data_url = 'https://data.cityofnewyork.us/api/views/7x9x-zpz6/rows.csv?accessType=DOWNLOAD'
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)