Commit 5010ebb8 authored by Charpentier Maxime's avatar Charpentier Maxime

minor changes

parent 75265a07
This diff is collapsed.
This diff is collapsed.
......@@ -11,6 +11,16 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5c9fc968",
"metadata": {},
"outputs": [],
"source": [
"#!conda install voila"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "ae4f0da1",
"metadata": {},
"outputs": [],
......@@ -21,8 +31,9 @@
"import geopandas as gpd\n",
"import pandas as pd\n",
"from IPython.display import display,clear_output\n",
"from branca.colormap import linear\n",
"from branca.colormap import linear, ColorMap\n",
"import json\n",
"from io import StringIO\n",
"#import plotly.express as px\n",
"#import plotly.graph_objects as go\n",
"%matplotlib inline\n",
......@@ -33,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "21cb58f3",
"metadata": {},
"outputs": [],
......@@ -43,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "76f19387",
"metadata": {},
"outputs": [],
......@@ -53,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "10f39562",
"metadata": {},
"outputs": [],
......@@ -71,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "93249907",
"metadata": {},
"outputs": [],
......@@ -85,7 +96,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "97b9938d",
"metadata": {},
"outputs": [],
......@@ -104,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "06718613",
"metadata": {
"scrolled": false
......@@ -113,26 +124,58 @@
"source": [
"mymap = ipyl.Map(center=(48.117266,-1.6777926), zoom=10, scroll_wheel_zoom=True)\n",
"\n",
"tranches = [\"P17_POP1524\", \"P17_POP2554\", \"P17_POP5579\", \"P17_POP80P\"]\n",
"csp_cols = [\"C17_PMEN_CS\"+str(k)for k in csp_cat]\n",
"\n",
"tranches_cols = {\"15-24\":1, \"25-54\":2, \"55-79\":3, \"80P\":4}\n",
"\n",
"geo_dep_demo_cantons = ipyl.GeoData(\n",
" geo_dataframe=gdep_demo_cantons,\n",
"values_rennes = {str(k):tranches_cols[grennes_demo[\"MOST_AGE\"].iloc[k]] for k in range(len(grennes_demo))}\n",
"\n",
"values_cantons = {str(k):tranches_cols[gdep_demo_cantons[\"MOST_AGE\"].iloc[k]] for k in range(len(gdep_demo_cantons))}\n",
"\n",
"\n",
"\n",
"geo_dep_demo_cantons = ipyl.Choropleth(\n",
" geo_data=json.load(StringIO(gdep_demo_cantons.to_json())),\n",
" choro_data=values_cantons,\n",
" colormap=linear.YlOrRd_04,\n",
" value_min=1,\n",
" value_max=4,\n",
" border_color='black',\n",
" style={'fillOpacity': 0.4, 'dashArray': '5, 5'},\n",
" hover_style={'fillOpacity': 0.8, 'dashArray': '5, 5'},\n",
" name=\"Département 35\")\n",
" style={'fillOpacity': 0.8, 'dashArray': '5, 5'},\n",
" \n",
")\n",
"\n",
"\n",
"# geo_dep_demo_cantons = ipyl.GeoData(\n",
"# geo_dataframe=gdep_demo_cantons,\n",
"# border_color='black',\n",
"# style={'fillOpacity': 0.4, 'dashArray': '5, 5'},\n",
"# hover_style={'fillOpacity': 0.8, 'dashArray': '5, 5'},\n",
"# name=\"Département 35\")\n",
"\n",
"\n",
"\n",
"\n",
"geo_dep_demo_rennes = ipyl.GeoData(\n",
" geo_dataframe=grennes_demo,\n",
"geo_dep_demo_rennes = ipyl.Choropleth(\n",
" geo_data=json.load(StringIO(grennes_demo.to_json())),\n",
" choro_data=values_rennes,\n",
" colormap=linear.YlOrRd_04,\n",
" value_min=1,\n",
" value_max=4,\n",
" border_color='black',\n",
" style={'fillOpacity': 0.4, 'dashArray': '5, 5'},\n",
" hover_style={'fillOpacity': 0.8, 'dashArray': '5, 5'},\n",
" name=\"IRIS Rennes\")\n",
" style={'fillOpacity': 0.8, 'dashArray': '5, 5'}\n",
")\n",
"\n",
"\n",
"# geo_dep_demo_rennes = ipyl.GeoData(\n",
"# geo_dataframe=grennes_demo,\n",
"# border_color='black',\n",
"# style={'fillOpacity': 0.4, 'dashArray': '5, 5'},\n",
"# hover_style={'fillOpacity': 0.8, 'dashArray': '5, 5'},\n",
"# name=\"IRIS Rennes\")\n",
"\n",
"\n",
"tranches = [\"P17_POP1524\", \"P17_POP2554\", \"P17_POP5579\", \"P17_POP80P\"]\n",
"csp_cols = [\"C17_PMEN_CS\"+str(k)for k in csp_cat]\n",
"visu_output = ipyw.Output()\n",
"\n",
"def age(ax, value):\n",
......@@ -206,7 +249,12 @@
" if event['new'] == 2:\n",
" csp(ax, value) \n",
"\n",
" \n",
"\n",
"legend = ipyl.LegendControl({\"15-24 ans\":linear.YlOrRd_04.scale(1,4)(1), \n",
" \"25-54 ans\":linear.YlOrRd_04.scale(1,4)(2), \n",
" \"55-79 ans\":linear.YlOrRd_04.scale(1,4)(3)}, name=\"Tranche majoritaire\", position=\"topright\")\n",
"mymap.add_control(legend)\n",
"\n",
"dropdown.observe(handler_dropdown, names=\"value\")\n",
" \n",
"controler = ipyl.LayersControl()\n",
......@@ -223,12 +271,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "8c3906af",
"metadata": {
"scrolled": false
},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f716d67038bf410fb6bcf4fc709103d4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Map(center=[48.117266, -1.6777926], controls=(ZoomControl(options=['position', 'zoom_in_text', …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"right = ipyw.VBox([dropdown, visu_output])\n",
"\n",
......@@ -239,6 +302,14 @@
"ipyw.HBox([mymap,\n",
" right])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "81dc51b4",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment