forked from ramirojc/PyConAr_GeoViz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_4.py
79 lines (59 loc) · 1.89 KB
/
app_4.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
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
import pandas as pd
mapbox_access_token = 'pk.eyJ1IjoiamFja2x1byIsImEiOiJjajNlcnh3MzEwMHZtMzNueGw3NWw5ZXF5In0.fk8k06T96Ml9CLGgKmk81w'
conj_name = {
15615: 'Boa Aventura',
16070: 'Nova Friburgo',
16068: 'Campo do Coelho',
15616: 'Vale dos Peoes',
16069: 'Conselheiro Paulino'
}
#################################
trd = pd.read_csv('./data/UNI_TRD_ENF17.csv')
#################################
######################
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='outdoors'),
margin=dict(l=0, t=0, b=0, r=0)
)
######################
app = dash.Dash(__name__)
server = app.server
app.layout = html.Div([
html.H1("Mapa de distribucion Electrica"),
html.H3("Seleccione Regiones"),
dcc.Dropdown(
id= 'dd_region',
multi= True,
options= [dict(label=conj_name[x], value=x) for x in trd.CONJ.unique()],
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)
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)