-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_fault_lines.py
65 lines (55 loc) · 1.61 KB
/
sample_fault_lines.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import dash
import pandas as pd
import plotly.graph_objs as go
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash(__name__)
with open('map_token.txt', 'r') as mk:
map_token = mk.read()
app.layout = html.Div([
dcc.Checklist(
id='display-plates',
options=[{'label' : 'Show Fault Lines', 'value' : 'Plates'}],
values=['Plates']
),
dcc.Graph(id='place-fault')
])
@app.callback(
Output('place-fault', 'figure'),
[Input('display-plates', 'values')]
)
def draw_fault_lines(values):
tectonic_plates = pd.read_csv('all_fault_lines.csv')
latitudes = tectonic_plates['latitudes']
longitudes = tectonic_plates['longitudes']
if values:
fault_lines = [
go.Scattermapbox(
lat=latitudes, lon=longitudes, mode='markers',
text='', hoverinfo='text', showlegend=False,
marker=dict(size=3, color='rgb(41,128,185)')
)
]
layout = go.Layout(
height=680, autosize=True, showlegend=False,
hovermode='closest',
geo=dict(
projection=dict(type="equirectangular"),
),
mapbox=dict(
accesstoken=map_token,
bearing=1,
# center=dict(lat=lats[0], lon=lons[0]),
pitch=0, zoom=1, style='dark'
)
)
return {'data' : fault_lines, 'layout' : layout}
external_css = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
for css in external_css:
app.css.append_css({'external_url' : css})
external_js = ['https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js']
for js in external_js:
app.scripts.append_script({'external_url' : js})
if __name__ == '__main__':
app.run_server(debug=True)