|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 81, |
| 6 | + "id": "09534296", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "from folium.plugins import VectorGridProtobuf\n", |
| 11 | + "import folium" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "code", |
| 16 | + "execution_count": 30, |
| 17 | + "id": "c044c77f", |
| 18 | + "metadata": {}, |
| 19 | + "outputs": [], |
| 20 | + "source": [ |
| 21 | + "styles = {\n", |
| 22 | + " \"water\": {\n", |
| 23 | + " \"fill\": True,\n", |
| 24 | + " \"weight\": 1,\n", |
| 25 | + " \"fillColor\": \"#06cccc\",\n", |
| 26 | + " \"color\": \"#06cccc\",\n", |
| 27 | + " \"fillOpacity\": 0.2,\n", |
| 28 | + " \"opacity\": 0.4\n", |
| 29 | + " },\n", |
| 30 | + " \"admin\": {\n", |
| 31 | + " \"weight\": 1,\n", |
| 32 | + " \"fillColor\": \"pink\",\n", |
| 33 | + " \"color\": \"pink\",\n", |
| 34 | + " \"fillOpacity\": 0.2,\n", |
| 35 | + " \"opacity\": 0.4\n", |
| 36 | + " },\n", |
| 37 | + " \"waterway\": {\n", |
| 38 | + " \"weight\": 1,\n", |
| 39 | + " \"fillColor\": \"#2375e0\",\n", |
| 40 | + " \"color\": \"#2375e0\",\n", |
| 41 | + " \"fillOpacity\": 0.2,\n", |
| 42 | + " \"opacity\": 0.4\n", |
| 43 | + " },\n", |
| 44 | + " \"landcover\": {\n", |
| 45 | + " \"fill\": True,\n", |
| 46 | + " \"weight\": 1,\n", |
| 47 | + " \"fillColor\": \"#53e033\",\n", |
| 48 | + " \"color\": \"#53e033\",\n", |
| 49 | + " \"fillOpacity\": 0.2,\n", |
| 50 | + " \"opacity\": 0.4\n", |
| 51 | + " },\n", |
| 52 | + " \"landuse\": {\n", |
| 53 | + " \"fill\": True,\n", |
| 54 | + " \"weight\": 1,\n", |
| 55 | + " \"fillColor\": \"#e5b404\",\n", |
| 56 | + " \"color\": \"#e5b404\",\n", |
| 57 | + " \"fillOpacity\": 0.2,\n", |
| 58 | + " \"opacity\": 0.4\n", |
| 59 | + " },\n", |
| 60 | + " \"park\": {\n", |
| 61 | + " \"fill\": True,\n", |
| 62 | + " \"weight\": 1,\n", |
| 63 | + " \"fillColor\": \"#84ea5b\",\n", |
| 64 | + " \"color\": \"#84ea5b\",\n", |
| 65 | + " \"fillOpacity\": 0.2,\n", |
| 66 | + " \"opacity\": 0.4\n", |
| 67 | + " },\n", |
| 68 | + " \"boundary\": {\n", |
| 69 | + " \"weight\": 1,\n", |
| 70 | + " \"fillColor\": \"#c545d3\",\n", |
| 71 | + " \"color\": \"#c545d3\",\n", |
| 72 | + " \"fillOpacity\": 0.2,\n", |
| 73 | + " \"opacity\": 0.4\n", |
| 74 | + " },\n", |
| 75 | + " \"aeroway\": {\n", |
| 76 | + " \"weight\": 1,\n", |
| 77 | + " \"fillColor\": \"#51aeb5\",\n", |
| 78 | + " \"color\": \"#51aeb5\",\n", |
| 79 | + " \"fillOpacity\": 0.2,\n", |
| 80 | + " \"opacity\": 0.4\n", |
| 81 | + " },\n", |
| 82 | + " \"building\": {\n", |
| 83 | + " \"fill\": True,\n", |
| 84 | + " \"weight\": 1,\n", |
| 85 | + " \"fillColor\": \"#2b2b2b\",\n", |
| 86 | + " \"color\": \"#2b2b2b\",\n", |
| 87 | + " \"fillOpacity\": 0.2,\n", |
| 88 | + " \"opacity\": 0.4\n", |
| 89 | + " },\n", |
| 90 | + " \"water_name\": {\n", |
| 91 | + " \"weight\": 1,\n", |
| 92 | + " \"fillColor\": \"#022c5b\",\n", |
| 93 | + " \"color\": \"#022c5b\",\n", |
| 94 | + " \"fillOpacity\": 0.2,\n", |
| 95 | + " \"opacity\": 0.4\n", |
| 96 | + " },\n", |
| 97 | + " \"transportation_name\": {\n", |
| 98 | + " \"weight\": 1,\n", |
| 99 | + " \"fillColor\": \"#bc6b38\",\n", |
| 100 | + " \"color\": \"#bc6b38\",\n", |
| 101 | + " \"fillOpacity\": 0.2,\n", |
| 102 | + " \"opacity\": 0.4\n", |
| 103 | + " },\n", |
| 104 | + " \"place\": {\n", |
| 105 | + " \"weight\": 1,\n", |
| 106 | + " \"fillColor\": \"#f20e93\",\n", |
| 107 | + " \"color\": \"#f20e93\",\n", |
| 108 | + " \"fillOpacity\": 0.2,\n", |
| 109 | + " \"opacity\": 0.4\n", |
| 110 | + " },\n", |
| 111 | + " \"housenumber\": {\n", |
| 112 | + " \"weight\": 1,\n", |
| 113 | + " \"fillColor\": \"#ef4c8b\",\n", |
| 114 | + " \"color\": \"#ef4c8b\",\n", |
| 115 | + " \"fillOpacity\": 0.2,\n", |
| 116 | + " \"opacity\": 0.4\n", |
| 117 | + " },\n", |
| 118 | + " \"poi\": {\n", |
| 119 | + " \"weight\": 1,\n", |
| 120 | + " \"fillColor\": \"#3bb50a\",\n", |
| 121 | + " \"color\": \"#3bb50a\",\n", |
| 122 | + " \"fillOpacity\": 0.2,\n", |
| 123 | + " \"opacity\": 0.4\n", |
| 124 | + " },\n", |
| 125 | + " \"road\": {\n", |
| 126 | + " \"weight\": 1,\n", |
| 127 | + " \"fillColor\": \"#f2b648\",\n", |
| 128 | + " \"color\": \"#f2b648\",\n", |
| 129 | + " \"fillOpacity\": 0.2,\n", |
| 130 | + " \"opacity\": 0.4\n", |
| 131 | + " },\n", |
| 132 | + "}" |
| 133 | + ] |
| 134 | + }, |
| 135 | + { |
| 136 | + "cell_type": "code", |
| 137 | + "execution_count": 92, |
| 138 | + "id": "725693fc", |
| 139 | + "metadata": {}, |
| 140 | + "outputs": [], |
| 141 | + "source": [ |
| 142 | + "vectorTileLayerStyles = {}\n", |
| 143 | + "vectorTileLayerStyles[\"aerodrome_label\"] = []\n", |
| 144 | + "vectorTileLayerStyles[\"aeroway\"] = []\n", |
| 145 | + "vectorTileLayerStyles[\"area_name\"] = []\n", |
| 146 | + "vectorTileLayerStyles[\"boundary\"] = styles[\"admin\"]\n", |
| 147 | + "vectorTileLayerStyles[\"building\"] = []\n", |
| 148 | + "vectorTileLayerStyles[\"building_ln\"] = []\n", |
| 149 | + "vectorTileLayerStyles[\"construct\"] = []\n", |
| 150 | + "vectorTileLayerStyles[\"contour_line\"] = []\n", |
| 151 | + "vectorTileLayerStyles[\"landcover\"] = styles[\"landcover\"]\n", |
| 152 | + "vectorTileLayerStyles[\"landuse\"] = styles[\"landuse\"]\n", |
| 153 | + "vectorTileLayerStyles[\"mountain_peak\"] = []\n", |
| 154 | + "vectorTileLayerStyles[\"park\"] = styles[\"park\"]\n", |
| 155 | + "vectorTileLayerStyles[\"place\"] = []\n", |
| 156 | + "vectorTileLayerStyles[\"poi\"] = []\n", |
| 157 | + "vectorTileLayerStyles[\"spot_elevation\"] = []\n", |
| 158 | + "vectorTileLayerStyles[\"transportation\"] = styles[\"road\"]\n", |
| 159 | + "vectorTileLayerStyles[\"transportation_name\"] = []\n", |
| 160 | + "vectorTileLayerStyles[\"water\"] = styles[\"water\"]\n", |
| 161 | + "vectorTileLayerStyles[\"waterway\"] = styles[\"water\"]\n", |
| 162 | + "vectorTileLayerStyles[\"water_name\"] = []" |
| 163 | + ] |
| 164 | + }, |
| 165 | + { |
| 166 | + "cell_type": "code", |
| 167 | + "execution_count": 97, |
| 168 | + "id": "49c9bf7a", |
| 169 | + "metadata": {}, |
| 170 | + "outputs": [ |
| 171 | + { |
| 172 | + "data": { |
| 173 | + "text/html": [ |
| 174 | + "<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 src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=%3C%21DOCTYPE%20html%3E%0A%3Chead%3E%20%20%20%20%0A%20%20%20%20%3Cmeta%20http-equiv%3D%22content-type%22%20content%3D%22text/html%3B%20charset%3DUTF-8%22%20/%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%3Cscript%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20L_NO_TOUCH%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20L_DISABLE_3D%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%3C/script%3E%0A%20%20%20%20%0A%20%20%20%20%3Cstyle%3Ehtml%2C%20body%20%7Bwidth%3A%20100%25%3Bheight%3A%20100%25%3Bmargin%3A%200%3Bpadding%3A%200%3B%7D%3C/style%3E%0A%20%20%20%20%3Cstyle%3E%23map%20%7Bposition%3Aabsolute%3Btop%3A0%3Bbottom%3A0%3Bright%3A0%3Bleft%3A0%3B%7D%3C/style%3E%0A%20%20%20%20%3Cscript%20src%3D%22https%3A//cdn.jsdelivr.net/npm/leaflet%401.6.0/dist/leaflet.js%22%3E%3C/script%3E%0A%20%20%20%20%3Cscript%20src%3D%22https%3A//code.jquery.com/jquery-1.12.4.min.js%22%3E%3C/script%3E%0A%20%20%20%20%3Cscript%20src%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js%22%3E%3C/script%3E%0A%20%20%20%20%3Cscript%20src%3D%22https%3A//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js%22%3E%3C/script%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//cdn.jsdelivr.net/npm/leaflet%401.6.0/dist/leaflet.css%22/%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css%22/%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css%22/%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css%22/%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css%22/%3E%0A%20%20%20%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22https%3A//cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css%22/%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cmeta%20name%3D%22viewport%22%20content%3D%22width%3Ddevice-width%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20initial-scale%3D1.0%2C%20maximum-scale%3D1.0%2C%20user-scalable%3Dno%22%20/%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cstyle%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23map_4b05f680d71e4c9bb2f663b45a87e500%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20position%3A%20relative%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20width%3A%20100.0%25%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20height%3A%20100.0%25%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20left%3A%200.0%25%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20top%3A%200.0%25%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C/style%3E%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%3Cscript%20src%3D%22https%3A//unpkg.com/leaflet.vectorgrid%40latest/dist/Leaflet.VectorGrid.bundled.js%22%3E%3C/script%3E%0A%3C/head%3E%0A%3Cbody%3E%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%22folium-map%22%20id%3D%22map_4b05f680d71e4c9bb2f663b45a87e500%22%20%3E%3C/div%3E%0A%20%20%20%20%20%20%20%20%0A%3C/body%3E%0A%3Cscript%3E%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20map_4b05f680d71e4c9bb2f663b45a87e500%20%3D%20L.map%28%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22map_4b05f680d71e4c9bb2f663b45a87e500%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20center%3A%20%5B46.8%2C%208.2%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20crs%3A%20L.CRS.EPSG3857%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zoom%3A%2014%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zoomControl%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20preferCanvas%3A%20false%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%29%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20var%20vector_grid_protobuf_653d81da7d714651bbab3d81229a2551%20%3D%20L.vectorGrid.protobuf%28%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%27https%3A//vectortiles3.geo.admin.ch/tiles/ch.swisstopo.leichte-basiskarte.vt/v1.0.0/%7Bz%7D/%7Bx%7D/%7By%7D.pbf%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%22vectorTileLayerStyles%22%3A%20%7B%22aerodrome_label%22%3A%20%5B%5D%2C%20%22aeroway%22%3A%20%5B%5D%2C%20%22area_name%22%3A%20%5B%5D%2C%20%22boundary%22%3A%20%7B%22color%22%3A%20%22pink%22%2C%20%22fillColor%22%3A%20%22pink%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22building%22%3A%20%5B%5D%2C%20%22building_ln%22%3A%20%5B%5D%2C%20%22construct%22%3A%20%5B%5D%2C%20%22contour_line%22%3A%20%5B%5D%2C%20%22landcover%22%3A%20%7B%22color%22%3A%20%22%2353e033%22%2C%20%22fill%22%3A%20true%2C%20%22fillColor%22%3A%20%22%2353e033%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22landuse%22%3A%20%7B%22color%22%3A%20%22%23e5b404%22%2C%20%22fill%22%3A%20true%2C%20%22fillColor%22%3A%20%22%23e5b404%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22mountain_peak%22%3A%20%5B%5D%2C%20%22park%22%3A%20%7B%22color%22%3A%20%22%2384ea5b%22%2C%20%22fill%22%3A%20true%2C%20%22fillColor%22%3A%20%22%2384ea5b%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22place%22%3A%20%5B%5D%2C%20%22poi%22%3A%20%5B%5D%2C%20%22spot_elevation%22%3A%20%5B%5D%2C%20%22transportation%22%3A%20%7B%22color%22%3A%20%22%23f2b648%22%2C%20%22fillColor%22%3A%20%22%23f2b648%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22transportation_name%22%3A%20%5B%5D%2C%20%22water%22%3A%20%7B%22color%22%3A%20%22%2306cccc%22%2C%20%22fill%22%3A%20true%2C%20%22fillColor%22%3A%20%22%2306cccc%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%2C%20%22water_name%22%3A%20%5B%5D%2C%20%22waterway%22%3A%20%7B%22color%22%3A%20%22%2306cccc%22%2C%20%22fill%22%3A%20true%2C%20%22fillColor%22%3A%20%22%2306cccc%22%2C%20%22fillOpacity%22%3A%200.2%2C%20%22opacity%22%3A%200.4%2C%20%22weight%22%3A%201%7D%7D%7D%29%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.addTo%28map_4b05f680d71e4c9bb2f663b45a87e500%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%3C/script%3E onload=\"this.contentDocument.open();this.contentDocument.write( decodeURIComponent(this.getAttribute('data-html')));this.contentDocument.close();\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" |
| 175 | + ], |
| 176 | + "text/plain": [ |
| 177 | + "<folium.folium.Map at 0x123d388e0>" |
| 178 | + ] |
| 179 | + }, |
| 180 | + "execution_count": 97, |
| 181 | + "metadata": {}, |
| 182 | + "output_type": "execute_result" |
| 183 | + } |
| 184 | + ], |
| 185 | + "source": [ |
| 186 | + "url = \"https://vectortiles3.geo.admin.ch/tiles/ch.swisstopo.leichte-basiskarte.vt/v1.0.0/{z}/{x}/{y}.pbf\"\n", |
| 187 | + "m = folium.Map(tiles=None, location=[46.8, 8.2], zoom_start=14)\n", |
| 188 | + "\n", |
| 189 | + "options = {\n", |
| 190 | + " \"vectorTileLayerStyles\": vectorTileLayerStyles\n", |
| 191 | + "}\n", |
| 192 | + "\n", |
| 193 | + "vc = VectorGridProtobuf(url, \"folium_layer_name\", options)\n", |
| 194 | + "m.add_child(vc)\n", |
| 195 | + "m" |
| 196 | + ] |
| 197 | + } |
| 198 | + ], |
| 199 | + "metadata": { |
| 200 | + "kernelspec": { |
| 201 | + "display_name": "Python 3", |
| 202 | + "language": "python", |
| 203 | + "name": "python3" |
| 204 | + }, |
| 205 | + "language_info": { |
| 206 | + "codemirror_mode": { |
| 207 | + "name": "ipython", |
| 208 | + "version": 3 |
| 209 | + }, |
| 210 | + "file_extension": ".py", |
| 211 | + "mimetype": "text/x-python", |
| 212 | + "name": "python", |
| 213 | + "nbconvert_exporter": "python", |
| 214 | + "pygments_lexer": "ipython3", |
| 215 | + "version": "3.7.10" |
| 216 | + } |
| 217 | + }, |
| 218 | + "nbformat": 4, |
| 219 | + "nbformat_minor": 5 |
| 220 | +} |
0 commit comments