awacke1 commited on
Commit
38532d2
·
1 Parent(s): c884fa8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pydeck as pdk
4
+
5
+ # create a container for the map and controls
6
+ container = st.container()
7
+
8
+ # load the data
9
+ data_url = 'https://data.cityofnewyork.us/api/views/7x9x-zpz6/rows.csv?accessType=DOWNLOAD'
10
+ data = pd.read_csv(data_url, usecols=['latitude', 'longitude', 'time'])
11
+
12
+ # create the scatter plot layer
13
+ scatter_layer = pdk.Layer(
14
+ 'ScatterplotLayer',
15
+ data=data,
16
+ get_position='[longitude, latitude]',
17
+ get_color='[200, 30, time / 100]',
18
+ get_radius=100,
19
+ pickable=True,
20
+ )
21
+
22
+ # create the PyDeck view
23
+ view = pdk.ViewState(latitude=data['latitude'].mean(),
24
+ longitude=data['longitude'].mean(),
25
+ zoom=10,
26
+ pitch=50)
27
+
28
+ # create the PyDeck map
29
+ map = pdk.Deck(layers=[scatter_layer], initial_view_state=view)
30
+
31
+ # add the PyDeck map to the container
32
+ with container:
33
+ st.pydeck_chart(map)