from jyquickhelper import add_notebook_menu
add_notebook_menu()
from papierstat.datasets import load_enedis_dataset
df = load_enedis_dataset()
df.head(n=2).T
0 | 1 | |
---|---|---|
Année | 2016 | 2016 |
Nom commune | Ponteilla | Varreddes |
Code commune | 66145 | 77483 |
Nom EPCI | CU Perpignan Méditerranée (Pmcu) | CA Pays de Meaux |
Code EPCI | 200027183 | 247700628 |
Type EPCI | CU | CA |
Nom département | Pyrénées-Orientales | Seine-et-Marne |
Code département | 66 | 77 |
Nom région | Occitanie | Île-de-France |
Code région | 76 | 11 |
Domaine de tension | BT > 36 kVA | BT <= 36 kVA |
Nb sites Photovoltaïque Enedis | 73 | 10 |
Energie produite annuelle Photovoltaïque Enedis (MWh) | 10728.6 | 21.4168 |
Nb sites Eolien Enedis | 0 | 0 |
Energie produite annuelle Eolien Enedis (MWh) | 0 | 0 |
Nb sites Hydraulique Enedis | 0 | 0 |
Energie produite annuelle Hydraulique Enedis (MWh) | 0 | 0 |
Nb sites Bio Energie Enedis | 0 | 0 |
Energie produite annuelle Bio Energie Enedis (MWh) | 0 | 0 |
Nb sites Cogénération Enedis | 0 | 0 |
Energie produite annuelle Cogénération Enedis (MWh) | 0 | 0 |
Nb sites Autres filières Enedis | 0 | 0 |
Energie produite annuelle Autres filières Enedis (MWh) | 0 | 0 |
Geo Point 2D | 42.6323626522, 2.82631103755 | 49.0059497861, 2.92725176893 |
long | 2.82631 | 2.92725 |
lat | 42.6324 | 49.0059 |
bokeh n'inclut aucune données géographiques, il faut les récupérer. Les pays sont disponibles à cette adresse github.com/johan.
from bokeh.io import show, reset_output
from bokeh.plotting import figure
from bokeh.models import GeoJSONDataSource
from bokeh.models import Range1d
from papierstat.datasets import get_geojson_countries
with open(get_geojson_countries(), "r") as f:
countries = GeoJSONDataSource(geojson=f.read())
tools = "pan,wheel_zoom,reset"
p = figure(width=1000, height=600, tools=tools, title='World Countries',
x_axis_label='Longitude', y_axis_label='Latitude')
p.background_fill_color = "aqua"
p.x_range = Range1d(start=-180, end=180)
p.y_range = Range1d(start=-90, end=90)
p.patches("xs", "ys", color="white", line_color="black", source=countries)
show(p)
Et plus spécifique autour de la France avec quelques animations.
from bokeh.models import ColumnDataSource, HoverTool, LogColorMapper
from bokeh.models.glyphs import Patches
tools = "pan,wheel_zoom,reset"
p = figure(width=500, height=400, tools=tools, title='World Countries',
x_axis_label='Longitude', y_axis_label='Latitude')
p.background_fill_color = "aqua"
p.x_range = Range1d(start=-5, end=10)
p.y_range = Range1d(start=42, end=52)
pat1 = Patches(xs="xs", ys="ys", fill_color="white", line_color="black")
p.add_glyph(countries, pat1)
communes = ColumnDataSource(data=dict(xc=df.long, yc=df.lat,
commune=df['Nom commune'],
tension=df['Domaine de tension']))
p.scatter(x="xc", y="yc", fill_color="blue", line_color="blue", source=communes)
hover = HoverTool(tooltips=[("->", "@commune"), ('T', "@tension")],
mode="mouse", point_policy="follow_mouse")
p.add_tools(hover)
try:
show(p)
except Exception as e:
# This graph sometimes shows the message
# Models must be owned by only a single document, GeoJSONDataSource(id='1002', ...
# You can try function reset_output()
# if this happens.
print(e)