-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (36 loc) · 1.55 KB
/
main.py
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
35
36
37
38
39
40
41
import streamlit as st
import pandas as pd
import numpy as np
import time
import plotly.express as px
# https://plotly.github.io/plotly.py-docs/generated/plotly.express.scatter_mapbox.html
# https://plotly.com/python/scattermapbox/
@st.cache
def data():
df = pd.read_csv('./train.csv')
return df
# traps.rename(columns={'Longitude':'longitude',
#'Latitude':'latitude'}, inplace=True) # st.map only recognised these col names
df = data()
trap_locations = df[['Longitude', 'Latitude','Trap','Date']].drop_duplicates()
# map
st.sidebar.title('🦟 Identifying presence of West Nile Virus per Trap')
st.sidebar.info('## All Traps 🪤 map')
# st.map(locations) # plots all points at once
px.set_mapbox_access_token(open('./.gitignore/.mapbox_token.txt').read())
# this format allows animation
fig = px.scatter_mapbox(trap_locations,
lat="Latitude",
lon="Longitude",
color="Trap",
color_discrete_sequence=['blue'],
size_max=15,
#animation_frame="Date",
zoom=9,
height=650,
title='Map showing Trap locations')
fig.update_layout(mapbox_style="carto-positron",
#mapbox_zoom=10,
mapbox_center = {"lat": 41.85, "lon": -87.63})
fig.update(layout_coloraxis_showscale=False) # removes default color scale on the side
st.plotly_chart(fig, use_container_width=True)