Skip to content

Instantly share code, notes, and snippets.

@ocefpaf
Created March 8, 2021 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocefpaf/8fc2c52fe15172a0ff09b24808aadca3 to your computer and use it in GitHub Desktop.
Save ocefpaf/8fc2c52fe15172a0ff09b24808aadca3 to your computer and use it in GitHub Desktop.
Folium layers
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import folium\nimport numpy as np\n\n\nlon = np.mean(80+170)\nlat = np.mean(-45+30)",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "m = folium.Map(\n location=[lat, 360-lon],\n tiles=None,\n zoom_start=3,\n)\n\nfolium.TileLayer(\n tiles = \"https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}\",\n attr=\"arcgis\",\n name=\"World_Ocean_Base\",\n show=True\n).add_to(m)\n\nfolium.TileLayer(\n tiles = \"https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}\",\n attr=\"arcgis\",\n name=\"World_Ocean_Reference\",\n show=True\n).add_to(m)\n\n\n\nm",
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 2,
"data": {
"text/plain": "<folium.folium.Map at 0x7fb45b9bf550>",
"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 src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=%3C%21DOCTYPE+html%3E%0A%3Chead%3E++++%0A++++%3Cmeta+http-equiv%3D%22content-type%22+content%3D%22text/html%3B+charset%3DUTF-8%22+/%3E%0A++++%0A++++++++%3Cscript%3E%0A++++++++++++L_NO_TOUCH+%3D+false%3B%0A++++++++++++L_DISABLE_3D+%3D+false%3B%0A++++++++%3C/script%3E%0A++++%0A++++%3Cstyle%3Ehtml%2C+body+%7Bwidth%3A+100%25%3Bheight%3A+100%25%3Bmargin%3A+0%3Bpadding%3A+0%3B%7D%3C/style%3E%0A++++%3Cstyle%3E%23map+%7Bposition%3Aabsolute%3Btop%3A0%3Bbottom%3A0%3Bright%3A0%3Bleft%3A0%3B%7D%3C/style%3E%0A++++%3Cscript+src%3D%22https%3A//cdn.jsdelivr.net/npm/leaflet%401.6.0/dist/leaflet.js%22%3E%3C/script%3E%0A++++%3Cscript+src%3D%22https%3A//code.jquery.com/jquery-1.12.4.min.js%22%3E%3C/script%3E%0A++++%3Cscript+src%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js%22%3E%3C/script%3E%0A++++%3Cscript+src%3D%22https%3A//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js%22%3E%3C/script%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//cdn.jsdelivr.net/npm/leaflet%401.6.0/dist/leaflet.css%22/%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css%22/%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css%22/%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css%22/%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css%22/%3E%0A++++%3Clink+rel%3D%22stylesheet%22+href%3D%22https%3A//cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css%22/%3E%0A++++%0A++++++++++++%3Cmeta+name%3D%22viewport%22+content%3D%22width%3Ddevice-width%2C%0A++++++++++++++++initial-scale%3D1.0%2C+maximum-scale%3D1.0%2C+user-scalable%3Dno%22+/%3E%0A++++++++++++%3Cstyle%3E%0A++++++++++++++++%23map_6d381b9e173644f69148e05340710da9+%7B%0A++++++++++++++++++++position%3A+relative%3B%0A++++++++++++++++++++width%3A+100.0%25%3B%0A++++++++++++++++++++height%3A+100.0%25%3B%0A++++++++++++++++++++left%3A+0.0%25%3B%0A++++++++++++++++++++top%3A+0.0%25%3B%0A++++++++++++++++%7D%0A++++++++++++%3C/style%3E%0A++++++++%0A%3C/head%3E%0A%3Cbody%3E++++%0A++++%0A++++++++++++%3Cdiv+class%3D%22folium-map%22+id%3D%22map_6d381b9e173644f69148e05340710da9%22+%3E%3C/div%3E%0A++++++++%0A%3C/body%3E%0A%3Cscript%3E++++%0A++++%0A++++++++++++var+map_6d381b9e173644f69148e05340710da9+%3D+L.map%28%0A++++++++++++++++%22map_6d381b9e173644f69148e05340710da9%22%2C%0A++++++++++++++++%7B%0A++++++++++++++++++++center%3A+%5B-15.0%2C+110.0%5D%2C%0A++++++++++++++++++++crs%3A+L.CRS.EPSG3857%2C%0A++++++++++++++++++++zoom%3A+3%2C%0A++++++++++++++++++++zoomControl%3A+true%2C%0A++++++++++++++++++++preferCanvas%3A+false%2C%0A++++++++++++++++%7D%0A++++++++++++%29%3B%0A%0A++++++++++++%0A%0A++++++++%0A++++%0A++++++++++++var+tile_layer_411f6834aa814f24aeea908a68137322+%3D+L.tileLayer%28%0A++++++++++++++++%22https%3A//server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D%22%2C%0A++++++++++++++++%7B%22attribution%22%3A+%22arcgis%22%2C+%22detectRetina%22%3A+false%2C+%22maxNativeZoom%22%3A+18%2C+%22maxZoom%22%3A+18%2C+%22minZoom%22%3A+0%2C+%22noWrap%22%3A+false%2C+%22opacity%22%3A+1%2C+%22subdomains%22%3A+%22abc%22%2C+%22tms%22%3A+false%7D%0A++++++++++++%29.addTo%28map_6d381b9e173644f69148e05340710da9%29%3B%0A++++++++%0A++++%0A++++++++++++var+tile_layer_8dfbf33330eb4bd89f2b7c808f4fe730+%3D+L.tileLayer%28%0A++++++++++++++++%22https%3A//server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D%22%2C%0A++++++++++++++++%7B%22attribution%22%3A+%22arcgis%22%2C+%22detectRetina%22%3A+false%2C+%22maxNativeZoom%22%3A+18%2C+%22maxZoom%22%3A+18%2C+%22minZoom%22%3A+0%2C+%22noWrap%22%3A+false%2C+%22opacity%22%3A+1%2C+%22subdomains%22%3A+%22abc%22%2C+%22tms%22%3A+false%7D%0A++++++++++++%29.addTo%28map_6d381b9e173644f69148e05340710da9%29%3B%0A++++++++%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>"
},
"metadata": {}
}
]
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.9.2",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Folium layers",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment