File size: 908 Bytes
38532d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)