1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-12-04 11:52:28 +00:00
sitc/ml21/visualization/06_Spatial_Charts.ipynb

690 lines
156 KiB
Plaintext
Raw Permalink Normal View History

2024-04-03 20:53:02 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"![](images/EscUpmPolit_p.gif \"UPM\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"# Course Notes for Learning Intelligent Systems"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## [Introduction to Visualization](00_Intro_Visualization.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Spatial charts\n",
"Charts for showing geographical information."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Maps\n",
"Showing a map. You should install **folium**."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
" \n",
" &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
" \n",
" &lt;script&gt;\n",
" L_NO_TOUCH = false;\n",
" L_DISABLE_3D = false;\n",
" &lt;/script&gt;\n",
" \n",
" &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
" &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
" \n",
" &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
" &lt;style&gt;\n",
" #map_10753c97c83dda53bf3f2bd9c1b59b1f {\n",
" position: relative;\n",
" width: 100.0%;\n",
" height: 100.0%;\n",
" left: 0.0%;\n",
" top: 0.0%;\n",
" }\n",
" .leaflet-container { font-size: 1rem; }\n",
" &lt;/style&gt;\n",
" \n",
"&lt;/head&gt;\n",
"&lt;body&gt;\n",
" \n",
" \n",
" &lt;div class=&quot;folium-map&quot; id=&quot;map_10753c97c83dda53bf3f2bd9c1b59b1f&quot; &gt;&lt;/div&gt;\n",
" \n",
"&lt;/body&gt;\n",
"&lt;script&gt;\n",
" \n",
" \n",
" var map_10753c97c83dda53bf3f2bd9c1b59b1f = L.map(\n",
" &quot;map_10753c97c83dda53bf3f2bd9c1b59b1f&quot;,\n",
" {\n",
" center: [45.5, 25.56667],\n",
" crs: L.CRS.EPSG3857,\n",
" zoom: 10,\n",
" zoomControl: true,\n",
" preferCanvas: false,\n",
" }\n",
" );\n",
"\n",
" \n",
"\n",
" \n",
" \n",
" var tile_layer_dbed7fdb04df56d25f6e0c103bc1253b = L.tileLayer(\n",
" &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
" {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
" ).addTo(map_10753c97c83dda53bf3f2bd9c1b59b1f);\n",
" \n",
"&lt;/script&gt;\n",
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7f475544dc30>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import folium\n",
"folium.Map(location=[45.5, 25.56667])"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Choroplethe map\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
" \n",
" &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
" \n",
" &lt;script&gt;\n",
" L_NO_TOUCH = false;\n",
" L_DISABLE_3D = false;\n",
" &lt;/script&gt;\n",
" \n",
" &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
" &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
" \n",
" &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
" &lt;style&gt;\n",
" #map_0c9c9008aa93000cd1e9b85695012b72 {\n",
" position: relative;\n",
" width: 100.0%;\n",
" height: 100.0%;\n",
" left: 0.0%;\n",
" top: 0.0%;\n",
" }\n",
" .leaflet-container { font-size: 1rem; }\n",
" &lt;/style&gt;\n",
" \n",
" &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js&quot;&gt;&lt;/script&gt;\n",
"&lt;/head&gt;\n",
"&lt;body&gt;\n",
" \n",
" \n",
" &lt;div class=&quot;folium-map&quot; id=&quot;map_0c9c9008aa93000cd1e9b85695012b72&quot; &gt;&lt;/div&gt;\n",
" \n",
"&lt;/body&gt;\n",
"&lt;script&gt;\n",
" \n",
" \n",
" var map_0c9c9008aa93000cd1e9b85695012b72 = L.map(\n",
" &quot;map_0c9c9008aa93000cd1e9b85695012b72&quot;,\n",
" {\n",
" center: [48.0, -102.0],\n",
" crs: L.CRS.EPSG3857,\n",
" zoom: 3,\n",
" zoomControl: true,\n",
" preferCanvas: false,\n",
" }\n",
" );\n",
"\n",
" \n",
"\n",
" \n",
" \n",
" var tile_layer_c31c1658d34eef60a0f149dd3d1cb98c = L.tileLayer(\n",
" &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
" {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
" ).addTo(map_0c9c9008aa93000cd1e9b85695012b72);\n",
" \n",
" \n",
" var choropleth_380395aa7595e86e82e5b7c28cc37d3d = L.featureGroup(\n",
" {}\n",
" ).addTo(map_0c9c9008aa93000cd1e9b85695012b72);\n",
" \n",
" \n",
" function geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_styler(feature) {\n",
" switch(feature.id) {\n",
" case &quot;AZ&quot;: case &quot;CT&quot;: case &quot;FL&quot;: case &quot;GA&quot;: case &quot;IL&quot;: case &quot;IN&quot;: case &quot;KY&quot;: case &quot;MI&quot;: case &quot;MS&quot;: case &quot;NY&quot;: case &quot;OR&quot;: case &quot;PA&quot;: case &quot;SC&quot;: \n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#31a354&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" case &quot;CA&quot;: case &quot;NV&quot;: case &quot;NJ&quot;: case &quot;NC&quot;: case &quot;RI&quot;: \n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#006837&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" case &quot;HI&quot;: case &quot;IA&quot;: case &quot;OK&quot;: case &quot;SD&quot;: case &quot;UT&quot;: case &quot;VT&quot;: case &quot;WY&quot;: \n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#d9f0a3&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" case &quot;ID&quot;: case &quot;KS&quot;: case &quot;LA&quot;: case &quot;MA&quot;: case &quot;MN&quot;: case &quot;MO&quot;: case &quot;MT&quot;: case &quot;NH&quot;: case &quot;TX&quot;: case &quot;VA&quot;: \n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#addd8e&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" case &quot;NE&quot;: case &quot;ND&quot;: \n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#ffffcc&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" default:\n",
" return {&quot;color&quot;: &quot;black&quot;, &quot;fillColor&quot;: &quot;#78c679&quot;, &quot;fillOpacity&quot;: 0.7, &quot;opacity&quot;: 0.2, &quot;weight&quot;: 1};\n",
" }\n",
" }\n",
"\n",
" function geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_onEachFeature(feature, layer) {\n",
" layer.on({\n",
" });\n",
" };\n",
" var geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1 = L.geoJson(null, {\n",
" onEachFeature: geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_onEachFeature,\n",
" \n",
" style: geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_styler,\n",
" });\n",
"\n",
" function geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_add (data) {\n",
" geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1\n",
" .addData(data)\n",
" .addTo(choropleth_380395aa7595e86e82e5b7c28cc37d3d);\n",
" }\n",
" geo_json_b9e9a7f28ed8ea1a8b2b59cbd3acb3b1_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [[[-87.359296, 35.00118], [-85.606675, 34.984749], [-85.431413, 34.124869], [-85.184951, 32.859696], [-85.069935, 32.580372], [-84.960397, 32.421541], [-85.004212, 32.322956], [-84.889196, 32.262709], [-85.058981, 32.13674], [-85.053504, 32.01077], [-85.141136, 31.840985], [-85.042551, 31.539753], [-85.113751, 31.27686], [-85.004212, 31.003013], [-85.497137, 30.997536], [-87.600282, 30.997536], [-87.633143, 30.86609], [-87.408589, 30.674397], [-87.446927, 30.510088], [-87.37025, 30.427934], [-87.518128, 30.280057], [-87.655051, 30.247195], [-87.90699, 30.411504], [-87.934375, 30.657966], [-88.011052, 30.685351], [-88.10416, 30.499135], [-88.137022, 30.318396], [-88.394438, 30.367688], [-88.471115, 31.895754], [-88.241084, 33.796253], [-88.098683, 34.891641], [-88.202745, 34.995703], [-87.359296, 35.00118]]], &quot;type&quot;: &quot;Polygon&quot;}, &quot;id&quot;: &quot;AL&quot;, &quot;properties&quot;: {&quot;name&quot;: &quot;Alabama&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [[[[-131.602021, 55.117982], [-131.569159, 55.28229], [-131.355558, 55.183705], [-131.38842, 55.01392], [-131.645836, 55.035827], [-131.602021, 55.117982]]], [[[-131.832052, 55.42469], [-131.645836, 55.304197], [-131.749898, 55.128935], [-131.832052, 55.189182], [-131.832052, 55.42469]]], [[[-132.976733, 56.437924], [-132.735747, 56.459832], [-132.631685, 56.421493], [-132.664547, 56.273616], [-132.878148, 56.240754], [-133.069841, 56.333862], [-132.976733, 56.437924]]], [[[-133.595627, 56.350293], [-133.162949, 56.317431], [-133.05341, 56.125739], [-132.620732, 55.912138], [-132.472854, 55.780691], [-132.4619, 55.671152], [-132.357838, 55.649245], [-132.341408, 55.506844], [-132.166146, 55.364444], [-132.144238, 55.238474], [-132.029222, 55.276813], [-131.97993, 55.178228], [-131.958022, 54.789365], [-132.029222, 54.701734], [-132.308546, 54.718165], [-132.385223, 54.915335], [-132.483808, 54.898904], [-132.686455, 55.046781], [-132.746701, 54.997489], [-132.916486, 55.046781], [-132.889102, 54.898904], [-132.73027, 54.937242], [-132.626209, 54.882473], [-132.675501, 54.679826], [-132.867194, 54.701734], [-133.157472, 54.95915], [-133.239626, 55.090597], [-133.223195, 55.22752], [-133.453227, 55.216566], [-133.453227, 55.320628], [-133.277964, 55.331582], [-133.102702, 55.42469], [-133.17938, 55.588998], [-133.387503, 55.62186], [-133.420365, 55.884753], [-133.497042, 56.0162], [-133.639442, 55.923092], [-133.694212, 56.070969], [-133.546335, 56.142169], [-133.666827, 56.311955], [-133.595627, 56.350293]]], [[[-133.738027, 55.556137], [-133.546335, 55.490413], [-133.414888, 55.572568], [-133.283441, 55.534229], [-133.420365, 55.386352], [-133.633966, 55.430167], [-133.738027, 55.556137]]], [[[-133.907813, 56.930849], [-134.050213, 57.029434], [-133.885905, 57.095157], [-133.343688, 57.002049], [-133.102702, 57.007526], [-132.932917, 56.82131], [-132.620732, 56.667956], [-132.653593, 56.55294], [-132.817901, 56.492694], [-133.042456, 56.520078], [-133.201287, 56.448878], [-133.420365, 56.492694], [-133.66135, 56.448878], [-133.710643, 56.684386], [-133.688735, 56.837741], [-133.869474, 56.843218], [-133.907813, 56.930849]]], [[[-134.115936, 56.48174], [-134.25286, 56.558417], [-134.400737, 56.722725], [-134.417168, 56.848695], [-134.296675, 56.908941], [-134.170706, 56.848695], [-134.143321, 56.952757], [-133.748981, 56.772017], [-133.710643, 56.596755], [-133.847566, 56.574848], [-133.935197, 56.377678], [-133.836612, 56.322908], [-133.957105, 56.092877], [-134.110459, 56.142169], [-134.132367, 55.999769], [-134.230952, 56.070969], [-134.291198, 56.350293], [-134.115936, 56.48174]]], [[[-134.636246, 56.28457], [-134.669107, 56.169554], [-134.806031, 56.235277], [-135.178463, 56.67891], [-135.413971, 56.810356], [-135.331817, 56.914418], [-135.424925, 57.166357], [-135.687818, 57.369004], [-135.419448, 57.566174], [-135.298955, 57.48402], [-135.063447, 57.41
"\n",
" \n",
" \n",
" var color_map_b10797f7b9b84b60d8ba6a41cb09c4b1 = {};\n",
"\n",
" \n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.color = d3.scale.threshold()\n",
" .domain([3.2, 3.214228456913828, 3.2284569138276553, 3.242685370741483, 3.256913827655311, 3.2711422845691382, 3.285370741482966, 3.299599198396794, 3.3138276553106216, 3.328056112224449, 3.3422845691382768, 3.3565130260521046, 3.370741482965932, 3.3849699398797597, 3.3991983967935875, 3.413426853707415, 3.4276553106212426, 3.4418837675350704, 3.4561122244488978, 3.4703406813627256, 3.4845691382765533, 3.498797595190381, 3.5130260521042085, 3.5272545090180363, 3.541482965931864, 3.5557114228456914, 3.569939879759519, 3.584168336673347, 3.598396793587175, 3.612625250501002, 3.62685370741483, 3.6410821643286577, 3.655310621242485, 3.669539078156313, 3.6837675350701407, 3.697995991983968, 3.712224448897796, 3.7264529058116236, 3.740681362725451, 3.7549098196392787, 3.7691382765531065, 3.7833667334669343, 3.7975951903807617, 3.8118236472945894, 3.8260521042084172, 3.8402805611222446, 3.8545090180360724, 3.8687374749499, 3.8829659318637275, 3.8971943887775553, 3.911422845691383, 3.9256513026052104, 3.9398797595190382, 3.954108216432866, 3.968336673346694, 3.982565130260521, 3.996793587174349, 4.011022044088176, 4.025250501002004, 4.039478957915832, 4.05370741482966, 4.0679358717434875, 4.082164328657315, 4.096392785571142, 4.11062124248497, 4.124849699398798, 4.1390781563126255, 4.153306613226453, 4.167535070140281, 4.181763527054109, 4.195991983967936, 4.210220440881764, 4.224448897795591, 4.238677354709419, 4.252905811623247, 4.267134268537074, 4.281362725450903, 4.2955911823647295, 4.309819639278557, 4.324048096192385, 4.338276553106213, 4.352505010020041, 4.3667334669338675, 4.380961923847696, 4.395190380761523, 4.409418837675351, 4.423647294589179, 4.4378757515030065, 4.452104208416834, 4.466332665330661, 4.480561122244489, 4.494789579158317, 4.509018036072145, 4.523246492985972, 4.5374749498998, 4.551703406813628, 4.565931863727455, 4.580160320641283, 4.59438877755511, 4.608617234468938, 4.622845691382766, 4.637074148296593, 4.651302605210422, 4.6655310621242485, 4.679759519038076, 4.693987975951904, 4.708216432865732, 4.72244488977956, 4.736673346693387, 4.750901803607215, 4.765130260521042, 4.77935871743487, 4.793587174348698, 4.8078156312625255, 4.822044088176353, 4.83627254509018, 4.850501002004008, 4.864729458917836, 4.878957915831664, 4.893186372745491, 4.907414829659319, 4.921643286573147, 4.935871743486974, 4.950100200400802, 4.9643286573146295, 4.978557114228457, 4.992785571142285, 5.007014028056112, 5.021242484969941, 5.0354709418837675, 5.049699398797595, 5.063927855711423, 5.078156312625251, 5.092384769539079, 5.1066132264529065, 5.120841683366734, 5.135070140280561, 5.149298597194389, 5.163527054108217, 5.177755511022045, 5.191983967935872, 5.206212424849699, 5.220440881763528, 5.234669338677355, 5.248897795591183, 5.26312625250501, 5.277354709418838, 5.291583166332666, 5.305811623246493, 5.320040080160322, 5.3342685370741485, 5.348496993987976, 5.362725450901804, 5.376953907815632, 5.39118236472946, 5.405410821643287, 5.419639278557115, 5.433867735470942, 5.44809619238477, 5.462324649298598, 5.476553106212425, 5.490781563126253, 5.50501002004008, 5.519238476953909, 5.533466933867736, 5.547695390781563, 5.561923847695391, 5.576152304609218, 5.590380761523047, 5.604609218436874, 5.618837675350702, 5.6330661322645295, 5.647294589178356, 5.661523046092185, 5.675751503006012, 5.68997995991984, 5.7042084168336675, 5.718436873747495, 5.732665330661323, 5.74689378757515, 5.761122244488979, 5.775350701402806, 5.789579158316633, 5.803807615230461, 5.818036072144289, 5.832264529058117, 5.846492985971945, 5.860721442885772, 5.874949899799599, 5.889178356713427, 5.903406813627255, 5.917635270541083, 5.93186372745491, 5.946092184368738, 5.960320641282566, 5.974549098196393, 5.988777555110221, 6.0030060120240485, 6.017234468937876, 6.031462925851704, 6.045691382765531, 6.05991983967936, 6.074148296593187, 6.088376753507014, 6.102605210420842, 6.116833667334669, 6.131062124248498, 6.145290581162325, 6.159519038076153, 6.17374749498998, 6.187975951903808, 6.202204408817636, 6.216432865731463, 6.23066
" .range([&#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#ffffccff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#d9f0a3ff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#x27;, &#x27;#addd8eff&#
" \n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x = d3.scale.linear()\n",
" .domain([3.2, 10.3])\n",
" .range([0, 450 - 50]);\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.legend = L.control({position: &#x27;topright&#x27;});\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.legend.onAdd = function (map) {var div = L.DomUtil.create(&#x27;div&#x27;, &#x27;legend&#x27;); return div};\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.legend.addTo(map_0c9c9008aa93000cd1e9b85695012b72);\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.xAxis = d3.svg.axis()\n",
" .scale(color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x)\n",
" .orient(&quot;top&quot;)\n",
" .tickSize(1)\n",
" .tickValues([3.2, 4.383333333333334, 5.566666666666666, 6.75, 7.933333333333334, 9.116666666666667, 10.3]);\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.svg = d3.select(&quot;.legend.leaflet-control&quot;).append(&quot;svg&quot;)\n",
" .attr(&quot;id&quot;, &#x27;legend&#x27;)\n",
" .attr(&quot;width&quot;, 450)\n",
" .attr(&quot;height&quot;, 40);\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.g = color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.svg.append(&quot;g&quot;)\n",
" .attr(&quot;class&quot;, &quot;key&quot;)\n",
" .attr(&quot;transform&quot;, &quot;translate(25,16)&quot;);\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.g.selectAll(&quot;rect&quot;)\n",
" .data(color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.color.range().map(function(d, i) {\n",
" return {\n",
" x0: i ? color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x(color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.color.domain()[i - 1]) : color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x.range()[0],\n",
" x1: i &lt; color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.color.domain().length ? color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x(color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.color.domain()[i]) : color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.x.range()[1],\n",
" z: d\n",
" };\n",
" }))\n",
" .enter().append(&quot;rect&quot;)\n",
" .attr(&quot;height&quot;, 40 - 30)\n",
" .attr(&quot;x&quot;, function(d) { return d.x0; })\n",
" .attr(&quot;width&quot;, function(d) { return d.x1 - d.x0; })\n",
" .style(&quot;fill&quot;, function(d) { return d.z; });\n",
"\n",
" color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.g.call(color_map_b10797f7b9b84b60d8ba6a41cb09c4b1.xAxis).append(&quot;text&quot;)\n",
" .attr(&quot;class&quot;, &quot;caption&quot;)\n",
" .attr(&quot;y&quot;, 21)\n",
" .text(&quot;Unemployment Rate (%)&quot;);\n",
" \n",
" var layer_control_59b1664b9ae6832dbdfea6b170a0ccbf = {\n",
" base_layers : {\n",
" &quot;openstreetmap&quot; : tile_layer_c31c1658d34eef60a0f149dd3d1cb98c,\n",
" },\n",
" overlays : {\n",
" &quot;choropleth&quot; : choropleth_380395aa7595e86e82e5b7c28cc37d3d,\n",
" },\n",
" };\n",
" L.control.layers(\n",
" layer_control_59b1664b9ae6832dbdfea6b170a0ccbf.base_layers,\n",
" layer_control_59b1664b9ae6832dbdfea6b170a0ccbf.overlays,\n",
" {&quot;autoZIndex&quot;: true, &quot;collapsed&quot;: true, &quot;position&quot;: &quot;topright&quot;}\n",
" ).addTo(map_0c9c9008aa93000cd1e9b85695012b72);\n",
" \n",
"&lt;/script&gt;\n",
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7f475544f1f0>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"\n",
"url = 'https://raw.githubusercontent.com/python-visualization/folium/master/examples/data'\n",
"state_geo = f'{url}/us-states.json'\n",
"state_unemployment = f'{url}/US_Unemployment_Oct2012.csv'\n",
"state_data = pd.read_csv(state_unemployment)\n",
"\n",
"m = folium.Map(location=[48, -102], zoom_start=3)\n",
"\n",
"folium.Choropleth(\n",
" geo_data=state_geo,\n",
" name='choropleth',\n",
" data=state_data,\n",
" columns=['State', 'Unemployment'],\n",
" key_on='feature.id',\n",
" fill_color='YlGn',\n",
" fill_opacity=0.7,\n",
" line_opacity=0.2,\n",
" legend_name='Unemployment Rate (%)'\n",
").add_to(m)\n",
"\n",
"folium.LayerControl().add_to(m)\n",
"\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>State</th>\n",
" <th>Unemployment</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>AL</td>\n",
" <td>7.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>AK</td>\n",
" <td>6.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>AZ</td>\n",
" <td>8.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>AR</td>\n",
" <td>7.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CA</td>\n",
" <td>10.1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" State Unemployment\n",
"0 AL 7.1\n",
"1 AK 6.8\n",
"2 AZ 8.1\n",
"3 AR 7.2\n",
"4 CA 10.1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"state_data.head(5)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import folium\n",
"\n",
"data = (\n",
" np.random.normal(size=(100, 3)) *\n",
" np.array([[1, 1, 1]]) +\n",
" np.array([[45, 25, 1]])\n",
").tolist()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
" \n",
" &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
" \n",
" &lt;script&gt;\n",
" L_NO_TOUCH = false;\n",
" L_DISABLE_3D = false;\n",
" &lt;/script&gt;\n",
" \n",
" &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
" &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
" \n",
" &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
" &lt;style&gt;\n",
" #map_7f635bde4c183a6496b74362a1412c1f {\n",
" position: relative;\n",
" width: 100.0%;\n",
" height: 100.0%;\n",
" left: 0.0%;\n",
" top: 0.0%;\n",
" }\n",
" .leaflet-container { font-size: 1rem; }\n",
" &lt;/style&gt;\n",
" \n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium@main/folium/templates/leaflet_heat.min.js&quot;&gt;&lt;/script&gt;\n",
"&lt;/head&gt;\n",
"&lt;body&gt;\n",
" \n",
" \n",
" &lt;div class=&quot;folium-map&quot; id=&quot;map_7f635bde4c183a6496b74362a1412c1f&quot; &gt;&lt;/div&gt;\n",
" \n",
"&lt;/body&gt;\n",
"&lt;script&gt;\n",
" \n",
" \n",
" var map_7f635bde4c183a6496b74362a1412c1f = L.map(\n",
" &quot;map_7f635bde4c183a6496b74362a1412c1f&quot;,\n",
" {\n",
" center: [45.5, 25.56667],\n",
" crs: L.CRS.EPSG3857,\n",
" zoom: 6,\n",
" zoomControl: true,\n",
" preferCanvas: false,\n",
" }\n",
" );\n",
"\n",
" \n",
"\n",
" \n",
" \n",
" var tile_layer_df2e80ff45c62b1cb053c6945df5f408 = L.tileLayer(\n",
" &quot;https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png&quot;,\n",
" {&quot;attribution&quot;: &quot;Map tiles by \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://stamen.com\\&quot;\\u003eStamen Design\\u003c/a\\u003e, under \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://creativecommons.org/licenses/by/3.0\\&quot;\\u003eCC BY 3.0\\u003c/a\\u003e. Data by \\u0026copy; \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca target=\\&quot;_blank\\&quot; href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
" ).addTo(map_7f635bde4c183a6496b74362a1412c1f);\n",
" \n",
" \n",
" var heat_map_a3bc80dc375c2c3d3654adf42ea4f051 = L.heatLayer(\n",
" [[43.62235681472994, 26.568505527596045, 0.49182615728394685], [44.4976396232618, 25.0115444030025, 2.0571786342551106], [46.22109491256618, 25.321787534260043, 1.9026435149612178], [43.74485607555257, 25.140563981325126, -0.3090093499122202], [45.22074103414042, 24.83247041249025, 0.29315080030561913], [45.48771868229699, 25.53866804476246, 1.1396024209139897], [43.007423625009, 25.384423173659822, 1.4738664558041057], [44.10482640271034, 24.52169993614013, 1.1395451759821513], [45.039732225692596, 23.483137883925146, 1.9750872574376042], [44.95508573487622, 25.98685838570842, 2.271837604543397], [43.13584761741731, 24.697400381544316, -0.4505651338468166], [43.940851235787534, 25.103903882315876, 1.7651371569385779], [45.58526022232475, 26.47412381006918, 2.003784427167313], [46.845750770154915, 26.701281975316363, 1.8863541126345482], [46.54572580264807, 26.55361887589343, 1.2062180960790414], [44.097283534949995, 23.151672224357867, 0.5312335675403816], [43.207646565104625, 24.815150280753702, 1.7402959130882205], [42.876903992941, 25.711962177308003, 0.8999716512082094], [45.876047227075766, 25.114635763988662, 1.888094521370324], [44.78630639218873, 25.588237557783913, 1.4888585444703635], [45.36458928193135, 24.182827624694998, 0.8090384630941582], [45.238882439974134, 24.216271370180245, 2.1505817669793714], [45.43882621079613, 24.031911671294278, -0.33467081102662455], [45.54974763314922, 24.500949641360176, 0.8854595388749171], [43.583667757783616, 25.135562495051246, 2.2939134869817734], [43.400989353387516, 26.83703621910271, -0.27330418133260315], [46.766111545224014, 24.37675120680769, 0.8399902520673865], [44.66823925672088, 25.610639409549858, -0.6699705673273979], [44.88579463268279, 25.185388663937086, 0.6111277506239743], [46.75631953126659, 22.51981056977864, -1.2320720318543277], [46.14788210626937, 24.88755733229663, 1.4943482514083284], [44.58265259672661, 25.48315353232797, -1.264769305727408], [44.63651747904148, 25.521573601364658, 1.2257426426391735], [44.097261308908635, 26.28980694266996, 0.7903261494299669], [43.5180426546007, 24.41775563741146, 2.2582433472913674], [45.43748891547579, 23.719703853870374, 2.017910449334929], [43.05427794294243, 25.570296461734443, -1.124525673740843], [45.94451970566149, 24.718820568228654, -1.4559038971675577], [44.4025066206608, 24.983714939132362, 0.1477619470057926], [44.08958957768476, 26.157205796697273, 1.882307593560515], [45.48374020549212, 25.01030608131657, -0.03760328964889936], [45.784428379081916, 26.147159288802165, 1.791767498074115], [45.63079988709774, 25.376093979472856, 1.7832865568246636], [46.897768837533796, 23.833356700768086, 1.3122142967039412], [46.43367019261663, 26.057602431786375, 0.9541685168245819], [43.92167222617511, 25.536462809057497, 2.345336348211255], [44.149831018581814, 25.00294152022472, 2.4489070868109213], [43.13118884168836, 26.245134620722006, 0.9946494537572931], [46.77519147779098, 25.702418270897045, 0.8702322171999125], [44.85599910706135, 24.376272258753083, 1.7225579026740057], [44.64655743145279, 25.02442100309076, 1.057870296167934], [45.58684570372787, 23.474896473425517, -0.5845893803541948], [45.225993030561945, 25.399412784577596, -0.2159446594093437], [46.11058903349467, 23.261308309417352, 0.7484445902750486], [47.45328514961796, 25.88486057917817, 1.351173147351711], [46.881452589745585, 23.168865597765777, 2.2717317155594188], [44.43170157936319, 23.807186175829695, 1.7367145389260297], [43.86671932883553, 25.332577384153126, 0.5799212918949168], [44.37213192882455, 25.14635656672337, 0.2990977818120588], [45.45786678516934, 23.894541943582773, 1.0244251250245926], [45.89133552130501, 25.052148687095414, 0.6171756296824591], [45.65200252884374, 25.945433154962718, 1.227268769529868], [44.50539151127526, 23.37295820348644, 0.7913148139941782], [44.14045620596139, 24.28324235610156, 1.4683303545117126], [43.142853803686684, 26.134527435231757, 0.4404287384291432], [45.76615818535968, 25.108975123812822, 0.9443177403809493], [44.0701753548321, 22.70109434046522, 3.30588970180
" {&quot;blur&quot;: 15, &quot;maxZoom&quot;: 18, &quot;minOpacity&quot;: 0.5, &quot;radius&quot;: 25}\n",
" ).addTo(map_7f635bde4c183a6496b74362a1412c1f);\n",
" \n",
"&lt;/script&gt;\n",
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7f46e59907c0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from folium.plugins import HeatMap\n",
"\n",
"m = folium.Map([45.5, 25.56667], tiles='stamentoner', zoom_start=6)\n",
"\n",
"HeatMap(data).add_to(m)\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"# References \n",
"* [Data Preprocessing for Machine learning in Python, GeeksForGeeks](https://www.geeksforgeeks.org/data-preprocessing-machine-learning-python/)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## Licence\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n",
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
]
}
],
"metadata": {
"datacleaner": {
"position": {
"top": "50px"
},
"python": {
"varRefreshCmd": "try:\n print(_datacleaner.dataframe_metadata())\nexcept:\n print([])"
},
"window_display": false
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}