{ "cells": [ { "cell_type": "code", "execution_count": 81, "id": "09534296", "metadata": {}, "outputs": [], "source": [ "from folium.plugins import VectorGridProtobuf\n", "import folium" ] }, { "cell_type": "code", "execution_count": 30, "id": "c044c77f", "metadata": {}, "outputs": [], "source": [ "styles = {\n", " \"water\": {\n", " \"fill\": True,\n", " \"weight\": 1,\n", " \"fillColor\": \"#06cccc\",\n", " \"color\": \"#06cccc\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"admin\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"pink\",\n", " \"color\": \"pink\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"waterway\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#2375e0\",\n", " \"color\": \"#2375e0\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"landcover\": {\n", " \"fill\": True,\n", " \"weight\": 1,\n", " \"fillColor\": \"#53e033\",\n", " \"color\": \"#53e033\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"landuse\": {\n", " \"fill\": True,\n", " \"weight\": 1,\n", " \"fillColor\": \"#e5b404\",\n", " \"color\": \"#e5b404\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"park\": {\n", " \"fill\": True,\n", " \"weight\": 1,\n", " \"fillColor\": \"#84ea5b\",\n", " \"color\": \"#84ea5b\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"boundary\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#c545d3\",\n", " \"color\": \"#c545d3\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"aeroway\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#51aeb5\",\n", " \"color\": \"#51aeb5\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"building\": {\n", " \"fill\": True,\n", " \"weight\": 1,\n", " \"fillColor\": \"#2b2b2b\",\n", " \"color\": \"#2b2b2b\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"water_name\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#022c5b\",\n", " \"color\": \"#022c5b\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"transportation_name\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#bc6b38\",\n", " \"color\": \"#bc6b38\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"place\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#f20e93\",\n", " \"color\": \"#f20e93\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"housenumber\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#ef4c8b\",\n", " \"color\": \"#ef4c8b\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"poi\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#3bb50a\",\n", " \"color\": \"#3bb50a\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", " \"road\": {\n", " \"weight\": 1,\n", " \"fillColor\": \"#f2b648\",\n", " \"color\": \"#f2b648\",\n", " \"fillOpacity\": 0.2,\n", " \"opacity\": 0.4\n", " },\n", "}" ] }, { "cell_type": "code", "execution_count": 92, "id": "725693fc", "metadata": {}, "outputs": [], "source": [ "vectorTileLayerStyles = {}\n", "vectorTileLayerStyles[\"aerodrome_label\"] = []\n", "vectorTileLayerStyles[\"aeroway\"] = []\n", "vectorTileLayerStyles[\"area_name\"] = []\n", "vectorTileLayerStyles[\"boundary\"] = styles[\"admin\"]\n", "vectorTileLayerStyles[\"building\"] = []\n", "vectorTileLayerStyles[\"building_ln\"] = []\n", "vectorTileLayerStyles[\"construct\"] = []\n", "vectorTileLayerStyles[\"contour_line\"] = []\n", "vectorTileLayerStyles[\"landcover\"] = styles[\"landcover\"]\n", "vectorTileLayerStyles[\"landuse\"] = styles[\"landuse\"]\n", "vectorTileLayerStyles[\"mountain_peak\"] = []\n", "vectorTileLayerStyles[\"park\"] = styles[\"park\"]\n", "vectorTileLayerStyles[\"place\"] = []\n", "vectorTileLayerStyles[\"poi\"] = []\n", "vectorTileLayerStyles[\"spot_elevation\"] = []\n", "vectorTileLayerStyles[\"transportation\"] = styles[\"road\"]\n", "vectorTileLayerStyles[\"transportation_name\"] = []\n", "vectorTileLayerStyles[\"water\"] = styles[\"water\"]\n", "vectorTileLayerStyles[\"waterway\"] = styles[\"water\"]\n", "vectorTileLayerStyles[\"water_name\"] = []" ] }, { "cell_type": "code", "execution_count": 97, "id": "49c9bf7a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "url = \"https://vectortiles3.geo.admin.ch/tiles/ch.swisstopo.leichte-basiskarte.vt/v1.0.0/{z}/{x}/{y}.pbf\"\n", "m = folium.Map(tiles=None, location=[46.8, 8.2], zoom_start=14)\n", "\n", "options = {\n", " \"vectorTileLayerStyles\": vectorTileLayerStyles\n", "}\n", "\n", "vc = VectorGridProtobuf(url, \"folium_layer_name\", options)\n", "m.add_child(vc)\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.10" } }, "nbformat": 4, "nbformat_minor": 5 }