Skip to content

Commit 774877d

Browse files
Merge pull request #895 from MackyDIARRA/nuclear
radiation notebook added in examples
2 parents 503bf7d + f82fe22 commit 774877d

File tree

1 file changed

+73
-11
lines changed

1 file changed

+73
-11
lines changed

examples/Radiation.ipynb

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,79 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 12,
66
"id": "43ef0082-9552-44e9-82d3-c1e27209d2c5",
77
"metadata": {
88
"tags": []
99
},
10-
"outputs": [],
10+
"outputs": [
11+
{
12+
"data": {
13+
"application/vnd.jupyter.widget-view+json": {
14+
"model_id": "620b5ab499a04a69bf13d9bbe53f6907",
15+
"version_major": 2,
16+
"version_minor": 0
17+
},
18+
"text/plain": [
19+
"Map(center=[47, 2], controls=(AttributionControl(options=['position', 'prefix'], position='bottomright'), Zoom…"
20+
]
21+
},
22+
"metadata": {},
23+
"output_type": "display_data"
24+
}
25+
],
1126
"source": [
12-
"from ipyleaflet import Map, TileLayer, FullScreenControl, ScaleControl\n",
27+
"import json\n",
28+
"import requests\n",
29+
"import random\n",
30+
"from ipyleaflet import Map, TileLayer, FullScreenControl, ScaleControl , ZoomControl, Marker , SearchControl , AwesomeIcon , WidgetControl, GeoJSON, Popup\n",
31+
"from ipywidgets import IntSlider, ColorPicker, Button, link, HTML, jslink\n",
32+
"m = Map(center=(47, 2), zoom=5, zoom_control = False )\n",
33+
"\n",
34+
"#create Zoom_control\n",
35+
"m.add_control(ZoomControl(position='topleft'))\n",
36+
"#create Scale_Control\n",
37+
"m.add_control(ScaleControl(position='bottomleft'))\n",
38+
"#Create Full_Screen_Control\n",
39+
"m.add_control(FullScreenControl())\n",
40+
"\n",
1341
"\n",
14-
"m = Map(center=(47, 2), zoom=5)\n",
42+
"zoom_slider = IntSlider(description='Zoom level:', min=0, max=15, value=7)\n",
43+
"jslink((zoom_slider, 'value'), (m, 'zoom'))\n",
44+
"widget_control1 = WidgetControl(widget=zoom_slider, position='topright')\n",
45+
"m.add_control(widget_control1)\n",
1546
"\n",
16-
"radon = TileLayer(url='https://cartoradon.irsn.fr/static/r/{z}/{x}/{y}.png',\n",
17-
" tms=True, opacity=0.5)\n",
47+
"\n",
48+
"#Create a local Tile Layer concerning the irsn map\n",
49+
"radon = TileLayer(url='https://cartoradon.irsn.fr/static/r/{z}/{x}/{y}.png',tms=True, opacity=0.5)\n",
1850
"m.add_layer(radon)\n",
1951
"\n",
20-
"fullscreen = FullScreenControl()\n",
21-
"m.add_control(fullscreen)\n",
22-
"scalecontrol = ScaleControl(position='bottomleft')\n",
23-
"m.add_control(scalecontrol)\n",
52+
"#Create a function get_data which fetch the datas from the irsn application\n",
53+
"def get_data():\n",
54+
" r = requests.get('https://cartoradon.irsn.fr/commune.py/communes/lonlat/{};{}'.format(lng,lat))\n",
55+
" return r.json()\n",
56+
"\n",
57+
"#take a method on_interation providing Map object to obtain the coordinates\n",
58+
"def on_interaction(event, type, coordinates):\n",
59+
" \n",
60+
" if type == 'click':\n",
61+
" data = get_data(coordinates[1], coordinates[0])\n",
62+
"\n",
63+
" # Display geojson\n",
64+
" geometry = data['geometry']\n",
65+
" geojson = GeoJSON(data=geometry,style={'opacity': 1, 'dashArray': '9', 'fillOpacity': 0.1, 'weight': 1},hover_style={'color': 'white', 'dashArray': '0', 'fillOpacity': 0.5})\n",
66+
" m.add_layer(geojson)\n",
67+
"\n",
68+
" # Create Popup\n",
69+
" message1 = HTML()\n",
70+
" dict_properties = data['properties']\n",
71+
" get_name = dict_properties.get('name')\n",
72+
" get_class = dict_properties.get('classr')\n",
73+
" message1.value = 'Ville: {}, Classe : {}'.format(get_name,get_class)\n",
74+
" popup = Popup(location= coordinates ,child=message1,close_button=True,auto_close=True,close_on_escape_key=False)\n",
75+
" m.add_layer(popup)\n",
76+
"m.on_interaction(on_interaction) \n",
77+
"\n",
2478
"m\n",
2579
"\n"
2680
]
@@ -34,6 +88,14 @@
3488
},
3589
"outputs": [],
3690
"source": []
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"id": "3312020d-cbd5-4f27-b9f0-845145da5811",
96+
"metadata": {},
97+
"outputs": [],
98+
"source": []
3799
}
38100
],
39101
"metadata": {
@@ -52,7 +114,7 @@
52114
"name": "python",
53115
"nbconvert_exporter": "python",
54116
"pygments_lexer": "ipython3",
55-
"version": "3.9.7"
117+
"version": "3.10.0"
56118
}
57119
},
58120
"nbformat": 4,

0 commit comments

Comments
 (0)