forked from ramirojc/PyConAr_GeoViz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_3.py
80 lines (59 loc) · 1.82 KB
/
app_3.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Output, Input, State
from plotly import graph_objs as go
#external_css = ['https://codepen.io/khan-sbm/pen/zYObZPx.css']
import pandas as pd
trd = pd.read_csv('./data/UNI_TRD_ENF17.csv')
conj_name = {
15615: 'Boa Aventura',
16070: 'Nova Friburgo',
16068: 'Campo do Coelho',
15616: 'Vale dos Peoes',
16069: 'Conselheiro Paulino'
}
mapbox_access_token = 'pk.eyJ1IjoiamFja2x1byIsImEiOiJjajNlcnh3MzEwMHZtMzNueGw3NWw5ZXF5In0.fk8k06T96Ml9CLGgKmk81w'
map_layout = go.Layout(
mapbox=go.layout.Mapbox(
accesstoken=mapbox_access_token,
center=dict(lat=trd.lat.mean(), lon=trd.lon.mean()),
zoom=10,
pitch=45,
style='streets'
),
margin=dict(t=10, r=10, b=10, l=10)
)
##############################################################
app = dash.Dash(__name__)
server = app.server
app.layout = html.Div([
html.H1("Mapa de distribucion Electrica"),
html.H3("Seleccionar Region"),
dcc.Dropdown(
id= 'dd_region',
options= [dict(label=conj_name[x], value=x) for x in trd.CONJ.unique()],
multi= True,
value= trd.CONJ.unique()
),
dcc.Graph(
id='map'
)
])
##############################################################
@app.callback(
Output(component_id='map', component_property='figure'),
[Input('dd_region','value')]
)
def update_map(region):
print(region)
data=[
go.Scattermapbox(
lat= trd.lat,
lon= trd.lon,
text= trd.COD_ID,
mode='markers',
)]
return go.Figure(data=data, layout=map_layout)
if __name__ == '__main__':
app.run_server(debug=True)