Visualize PMTiles in 3D
This notebook demonstrates how to visualize Overture Open Buildings in 3D.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install -U "leafmap[maplibre]"
# %pip install -U "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
url = "https://data.source.coop/cholmes/overture/overture-buildings.pmtiles"
metadata = leafmap.pmtiles_metadata(url)
print(f"layer names: {metadata['layer_names']}")
print(f"bounds: {metadata['bounds']}")
url = "https://data.source.coop/cholmes/overture/overture-buildings.pmtiles"
metadata = leafmap.pmtiles_metadata(url)
print(f"layer names: {metadata['layer_names']}")
print(f"bounds: {metadata['bounds']}")
layer names: ['buildings'] bounds: [-179.9999966, -83.6500138, 179.9972908, 82.5257812]
In [4]:
Copied!
m = leafmap.Map(
center=[-74.0095, 40.7046], zoom=16, pitch=60, bearing=-17, style="positron"
)
m.add_basemap("OpenStreetMap.Mapnik")
m.add_basemap("Esri.WorldImagery", visible=False)
style = {
"layers": [
{
"id": "buildings",
"source": "example_source",
"source-layer": "buildings",
"type": "fill-extrusion",
"filter": [
">",
["get", "height"],
0,
], # only show buildings with height info
"paint": {
"fill-extrusion-color": [
"interpolate",
["linear"],
["get", "height"],
0,
"lightgray",
200,
"royalblue",
400,
"lightblue",
],
"fill-extrusion-height": ["*", ["get", "height"], 1],
},
},
],
}
m.add_pmtiles(
url,
style=style,
visible=True,
opacity=1.0,
tooltip=True,
template="Height: {{height}}<br>Country: {{country_iso}}",
fit_bounds=False,
)
m.add_layer_control()
m
m = leafmap.Map(
center=[-74.0095, 40.7046], zoom=16, pitch=60, bearing=-17, style="positron"
)
m.add_basemap("OpenStreetMap.Mapnik")
m.add_basemap("Esri.WorldImagery", visible=False)
style = {
"layers": [
{
"id": "buildings",
"source": "example_source",
"source-layer": "buildings",
"type": "fill-extrusion",
"filter": [
">",
["get", "height"],
0,
], # only show buildings with height info
"paint": {
"fill-extrusion-color": [
"interpolate",
["linear"],
["get", "height"],
0,
"lightgray",
200,
"royalblue",
400,
"lightblue",
],
"fill-extrusion-height": ["*", ["get", "height"], 1],
},
},
],
}
m.add_pmtiles(
url,
style=style,
visible=True,
opacity=1.0,
tooltip=True,
template="Height: {{height}}
Country: {{country_iso}}", fit_bounds=False, ) m.add_layer_control() m
Country: {{country_iso}}", fit_bounds=False, ) m.add_layer_control() m