forked from ramirojc/PyConAr_GeoViz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_5.py
125 lines (97 loc) · 3.54 KB
/
app_5.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from plotly import graph_objs as go
import pandas as pd
##################################################
trd = pd.read_csv('./data/UNI_TRD_ENF17.csv')
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='light'),
margin= dict(l=0,t=0,b=0,r=0)
)
conj_name = {
15615: 'Boa Aventura',
16070: 'Nova Friburgo',
16068: 'Campo do Coelho',
15616: 'Vale dos Peoes',
16069: 'Conselheiro Paulino'
}
##################################################
app = dash.Dash(__name__)
server = app.server
###################################################
# Layout
###################################################
app.layout = html.Div([
html.Div([
html.H2("Mapa de distribucion Electrica")
], className='row'),
html.Div([
html.Div([
html.H6("Seleccione Regiones"),
dcc.Dropdown(
id= 'dd_region',
multi= True,
placeholder= 'Regiones',
options= [dict(label=conj_name[x], value=x) for x in trd.CONJ.unique()],
value= trd.CONJ.unique())
], className= 'pretty_container four columns'),
html.Div([
html.H6("Codificacion color"),
dcc.RadioItems(
id= 'ra_color_cod',
options= [
dict(label='Frecuencia de Cortes', value='FIC'),
dict(label='Duracion Media de Cortes', value='DIC'),
dict(label='Grupo Electrico', value='CONJ')],
value= 'FIC'
)
], className= 'pretty_container four columns'),
html.Div([
html.H6("Codificacion tamaño"),
dcc.RadioItems(
id= 'ra_size_cod',
options= [
dict(label='Duracion Media de Cortes', value='DIC'),
dict(label='Consumo Total', value='ENE_12'),
dict(label='Perdidas Transformador', value='PER_TOT')],
value= 'DIC'
)
], className= 'pretty_container four columns')
], className='row'),
html.Div([
html.Div([
dcc.Graph(id = 'map')
], className= 'pretty_container eight columns'),
html.Div([
dcc.Graph(id= 'aux-graph')
], className= 'pretty_container four columns')
], className='row')
], className= 'mainContainer')
###################################################
# CallBacks
###################################################
@app.callback(
Output(component_id='map', component_property='figure'),
[Input(component_id='dd_region', component_property='value')]
)
def update_map(region):
print(region)
trd_selecion = trd[trd.CONJ.isin(region)]
map_data=[
go.Scattermapbox(
lat=trd_selecion.lat,
lon=trd_selecion.lon,
mode='markers')
]
return go.Figure(data= map_data, layout= map_layout)
#####################################################
if __name__ == '__main__':
app.run_server(debug=True)