Spaces:
Running
Running
File size: 5,148 Bytes
873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 cc4c8ba 873af12 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
{
"cells": [
{
"cell_type": "markdown",
"id": "6527891f",
"metadata": {},
"source": [
"[](https://demo.leafmap.org/lab/index.html?path=notebooks/02_using_basemaps.ipynb)\n",
"[](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n",
"[](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",
"[](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n",
"[](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
}
|