-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add 3D PMTiles example * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9f27657
commit 92260aa
Showing
3 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0", | ||
"metadata": {}, | ||
"source": [ | ||
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/3d_pmtiles.ipynb)\n", | ||
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/3d_pmtiles.ipynb)\n", | ||
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", | ||
"\n", | ||
"**Visualize PMTiles in 3D**\n", | ||
"\n", | ||
"This notebook demonstrates how to visualize [Overture Open Buildings](https://beta.source.coop/cholmes/overture/overture-buildings.pmtiles) in 3D.\n", | ||
"\n", | ||
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# %pip install -U \"leafmap[maplibre]\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import leafmap.maplibregl as leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"url = \"https://data.source.coop/cholmes/overture/overture-buildings.pmtiles\"\n", | ||
"metadata = leafmap.pmtiles_metadata(url)\n", | ||
"print(f\"layer names: {metadata['layer_names']}\")\n", | ||
"print(f\"bounds: {metadata['bounds']}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = leafmap.Map(\n", | ||
" center=[-74.0095, 40.7046], zoom=16, pitch=60, bearing=-17, style=\"positron\"\n", | ||
")\n", | ||
"m.add_basemap(\"OpenStreetMap.Mapnik\")\n", | ||
"m.add_basemap(\"Esri.WorldImagery\", visible=False)\n", | ||
"\n", | ||
"style = {\n", | ||
" \"layers\": [\n", | ||
" {\n", | ||
" \"id\": \"buildings\",\n", | ||
" \"source\": \"example_source\",\n", | ||
" \"source-layer\": \"buildings\",\n", | ||
" \"type\": \"fill-extrusion\",\n", | ||
" \"filter\": [\n", | ||
" \">\",\n", | ||
" [\"get\", \"height\"],\n", | ||
" 0,\n", | ||
" ], # only show buildings with height info\n", | ||
" \"paint\": {\n", | ||
" \"fill-extrusion-color\": [\n", | ||
" \"interpolate\",\n", | ||
" [\"linear\"],\n", | ||
" [\"get\", \"height\"],\n", | ||
" 0,\n", | ||
" \"lightgray\",\n", | ||
" 200,\n", | ||
" \"royalblue\",\n", | ||
" 400,\n", | ||
" \"lightblue\",\n", | ||
" ],\n", | ||
" \"fill-extrusion-height\": [\"*\", [\"get\", \"height\"], 1],\n", | ||
" },\n", | ||
" },\n", | ||
" ],\n", | ||
"}\n", | ||
"\n", | ||
"m.add_pmtiles(\n", | ||
" url,\n", | ||
" style=style,\n", | ||
" visible=True,\n", | ||
" opacity=1.0,\n", | ||
" tooltip=True,\n", | ||
" template=\"Height: {{height}}<br>Country: {{country_iso}}\",\n", | ||
" fit_bounds=False,\n", | ||
")\n", | ||
"m.add_layer_control()\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "5", | ||
"metadata": {}, | ||
"source": [ | ||
"![](https://i.imgur.com/113bGei.png)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.11.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters