Skip to content

Commit

Permalink
Update MapLibre notebook examples (#811)
Browse files Browse the repository at this point in the history
* Update MapLiber notebook examples

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix API key issue

* Pin numpy version

* Add YouTube video tutorials

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
giswqs and pre-commit-ci[bot] committed Jul 4, 2024
1 parent f398559 commit a4c46a1
Show file tree
Hide file tree
Showing 68 changed files with 350 additions and 785 deletions.
13 changes: 7 additions & 6 deletions docs/maplibre/3d_buildings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import leafmap.maplibregl as leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -47,6 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
Expand All @@ -56,8 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")\n",
"style = f\"https://api.maptiler.com/maps/basic-v2/style.json?key={MAPTILER_KEY}\""
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")"
]
},
{
Expand All @@ -66,7 +65,9 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[-74.0066, 40.7135], zoom=16, pitch=45, bearing=-17, style=style)\n",
"m = leafmap.Map(\n",
" center=[-74.0066, 40.7135], zoom=16, pitch=45, bearing=-17, style=\"basic-v2\"\n",
")\n",
"source = {\n",
" \"url\": f\"https://api.maptiler.com/tiles/v3/tiles.json?key={MAPTILER_KEY}\",\n",
" \"type\": \"vector\",\n",
Expand Down Expand Up @@ -136,7 +137,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
5 changes: 3 additions & 2 deletions docs/maplibre/3d_terrain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -46,6 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
Expand Down Expand Up @@ -143,7 +144,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
18 changes: 4 additions & 14 deletions docs/maplibre/_template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import leafmap.maplibregl as leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -47,6 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
Expand All @@ -56,17 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")\n",
"style = f\"https://api.maptiler.com/maps/streets/style.json?key={MAPTILER_KEY}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[-100, 40], zoom=3, style=style)\n",
"m = leafmap.Map(center=[-100, 40], zoom=3, style=\"streets\")\n",
"m"
]
}
Expand All @@ -87,7 +77,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions docs/maplibre/add_3d_buildings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import time\n",
"import leafmap.maplibregl as leafmap"
]
Expand All @@ -39,7 +38,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -48,6 +47,7 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
Expand Down Expand Up @@ -116,7 +116,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
22 changes: 6 additions & 16 deletions docs/maplibre/add_colorbar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import leafmap.maplibregl as leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -47,19 +46,10 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")\n",
"style = f\"https://api.maptiler.com/maps/streets/style.json?key={MAPTILER_KEY}\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -75,7 +65,7 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(style=style)\n",
"m = leafmap.Map(style=\"streets\")\n",
"m.add_cog_layer(\n",
" dem, name=\"DEM\", colormap_name=\"terrain\", rescale=\"0, 4000\", fit_bounds=True\n",
")\n",
Expand All @@ -98,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(style=style)\n",
"m = leafmap.Map(style=\"streets\")\n",
"m.add_cog_layer(\n",
" dem, name=\"DEM\", colormap_name=\"terrain\", rescale=\"0, 4000\", fit_bounds=True\n",
")\n",
Expand Down Expand Up @@ -126,7 +116,7 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(style=style)\n",
"m = leafmap.Map(style=\"streets\")\n",
"m.add_cog_layer(\n",
" dem, name=\"DEM\", colormap_name=\"terrain\", rescale=\"0, 4000\", fit_bounds=True\n",
")\n",
Expand Down Expand Up @@ -167,7 +157,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
7 changes: 3 additions & 4 deletions docs/maplibre/add_deckgl_layer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import leafmap.maplibregl as leafmap"
]
},
Expand Down Expand Up @@ -78,7 +77,7 @@
"source": [
"m = leafmap.Map(\n",
" style=\"positron\",\n",
" center=(49.254, -123.13),\n",
" center=(-123.13, 49.254),\n",
" zoom=11,\n",
" pitch=45,\n",
")\n",
Expand Down Expand Up @@ -135,7 +134,7 @@
"m = leafmap.Map(\n",
" style=\"positron\",\n",
" center=(51.47, 0.45),\n",
" zoom=4,\n",
" zoom=1,\n",
" pitch=30,\n",
")\n",
"deck_geojson_layer = {\n",
Expand Down Expand Up @@ -201,7 +200,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
18 changes: 4 additions & 14 deletions docs/maplibre/add_image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import leafmap.maplibregl as leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -47,6 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
Expand All @@ -56,17 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")\n",
"style = f\"https://api.maptiler.com/maps/streets/style.json?key={MAPTILER_KEY}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[0.349419, -1.80921], zoom=3, style=style)\n",
"m = leafmap.Map(center=[0.349419, -1.80921], zoom=3, style=\"streets\")\n",
"image = \"https://upload.wikimedia.org/wikipedia/commons/7/7c/201408_cat.png\"\n",
"source = {\n",
" \"type\": \"geojson\",\n",
Expand Down Expand Up @@ -121,7 +111,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
18 changes: 4 additions & 14 deletions docs/maplibre/add_image_generated.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import numpy as np\n",
"import leafmap.maplibregl as leafmap"
]
Expand All @@ -39,7 +38,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can set it as an environment variable in your notebook or script as follows:"
"To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable."
]
},
{
Expand All @@ -48,19 +47,10 @@
"metadata": {},
"outputs": [],
"source": [
"# import os\n",
"# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"MAPTILER_KEY = leafmap.get_api_key(\"MAPTILER_KEY\")\n",
"style = f\"https://api.maptiler.com/maps/streets/style.json?key={MAPTILER_KEY}\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -90,7 +80,7 @@
" \"data\": flat_data.tolist(),\n",
"}\n",
"\n",
"m = leafmap.Map(center=[0, 0], zoom=1, style=style)\n",
"m = leafmap.Map(center=[0, 0], zoom=1, style=\"streets\")\n",
"m.add_image(\"gradient\", image_dict)\n",
"source = {\n",
" \"type\": \"geojson\",\n",
Expand Down Expand Up @@ -138,7 +128,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit a4c46a1

Please sign in to comment.