{ "cells": [ { "cell_type": "markdown", "id": "6527891f", "metadata": {}, "source": [ "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/02_using_basemaps.ipynb)\n", "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n", "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/02_using_basemaps.ipynb&branch=master)\n", "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n", "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder)\n", "\n", "**Using basemaps in leafmap**\n", "\n", "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "id": "d2c546a9", "metadata": {}, "outputs": [], "source": [ "# !pip install leafmap" ] }, { "cell_type": "code", "execution_count": null, "id": "a058f796", "metadata": {}, "outputs": [], "source": [ "import leafmap" ] }, { "cell_type": "markdown", "id": "88961a9f", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "id": "b9c9302e", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map()\n", "m" ] }, { "cell_type": "markdown", "id": "1fbc670a", "metadata": {}, "source": [ "Specify a Google basemap to use, can be one of [\"ROADMAP\", \"TERRAIN\", \"SATELLITE\", \"HYBRID\"]." ] }, { "cell_type": "code", "execution_count": null, "id": "3cabfa3f", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map(google_map=\"HYBRID\")\n", "m" ] }, { "cell_type": "code", "execution_count": null, "id": "a5b34cbd", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map(google_map=\"TERRAIN\")\n", "m" ] }, { "cell_type": "markdown", "id": "5f88fc6a", "metadata": {}, "source": [ "Add a basemap using the `add_basemap()` function." ] }, { "cell_type": "code", "execution_count": null, "id": "80eb3571", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map()\n", "m.add_basemap(\"HYBRID\")\n", "m.add_basemap(\"Esri.NatGeoWorldMap\")\n", "m" ] }, { "cell_type": "markdown", "id": "aacb1f95", "metadata": {}, "source": [ "Add an XYZ tile layer." ] }, { "cell_type": "code", "execution_count": null, "id": "cbe08c0b", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map()\n", "m.add_tile_layer(\n", " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n", " name=\"Google Satellite\",\n", " attribution=\"Google\",\n", ")\n", "m" ] }, { "cell_type": "markdown", "id": "fb33bb83", "metadata": {}, "source": [ "Add a WMS tile layer." ] }, { "cell_type": "code", "execution_count": null, "id": "c294d2b2", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map()\n", "naip_url = 'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?'\n", "m.add_wms_layer(\n", " url=naip_url, layers='0', name='NAIP Imagery', format='image/png', shown=True\n", ")\n", "m" ] }, { "cell_type": "markdown", "id": "3661053f", "metadata": {}, "source": [ "Add a legend to the map." ] }, { "cell_type": "code", "execution_count": null, "id": "968cad3f", "metadata": {}, "outputs": [], "source": [ "m = leafmap.Map(google_map=\"HYBRID\")\n", "\n", "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n", "m.add_wms_layer(\n", " url1, layers=\"1\", format='image/png', transparent=True, name=\"NWI Wetlands Vector\"\n", ")\n", "\n", "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n", "m.add_wms_layer(\n", " url2, layers=\"0\", format='image/png', transparent=True, name=\"NWI Wetlands Raster\"\n", ")\n", "\n", "m.add_legend(builtin_legend=\"NWI\")\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.10.8" } }, "nbformat": 4, "nbformat_minor": 5 }