Extrude polygons for 3D indoor mapping
This source code of this example is adapted from the MapLibre GL JS example - Extrude polygons for 3D indoor mapping.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
data = "https://maplibre.org/maplibre-gl-js/docs/assets/indoor-3d-map.geojson"
gdf = leafmap.geojson_to_gdf(data)
gdf.explore()
data = "https://maplibre.org/maplibre-gl-js/docs/assets/indoor-3d-map.geojson"
gdf = leafmap.geojson_to_gdf(data)
gdf.explore()
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
Copied!
gdf.head()
gdf.head()
Out[4]:
id | level | name | height | base_height | color | geometry | |
---|---|---|---|---|---|---|---|
0 | 06e8fa0b3f851e3ae0e1da5fc17e111e | 1 | Bird Exhibit | 0 | 0 | orange | POLYGON ((-87.61831 41.86628, -87.61832 41.866... |
1 | 08a10ab2bf15c4d14669b588062f7f08 | 1 | Bird Exhibit | 40 | 0 | grey | POLYGON ((-87.61781 41.86627, -87.61781 41.866... |
2 | 09ead44537d94ece576c7bc001c33e53 | 1 | East Hallway | 0 | 0 | indigo | POLYGON ((-87.6167 41.86614, -87.61671 41.8663... |
3 | 12251ebf764b36cf3b8c5ad42e2deb29 | 1 | East Entrance | 0 | 0 | violet | POLYGON ((-87.61544 41.86615, -87.61545 41.866... |
4 | 1ce4f8c186a40b9927006644e27bfd69 | 1 | Under the Earth | 0 | 0 | red | POLYGON ((-87.6167 41.86582, -87.6167 41.86612... |
In [5]:
Copied!
m = leafmap.Map(
center=(-87.61694, 41.86625), zoom=17, pitch=40, bearing=20, style="positron"
)
m.add_basemap("OpenStreetMap.Mapnik")
m.add_geojson(
data,
layer_type="fill-extrusion",
name="floorplan",
paint={
"fill-extrusion-color": ["get", "color"],
"fill-extrusion-height": ["get", "height"],
"fill-extrusion-base": ["get", "base_height"],
"fill-extrusion-opacity": 0.5,
},
)
m.add_layer_control()
m
m = leafmap.Map(
center=(-87.61694, 41.86625), zoom=17, pitch=40, bearing=20, style="positron"
)
m.add_basemap("OpenStreetMap.Mapnik")
m.add_geojson(
data,
layer_type="fill-extrusion",
name="floorplan",
paint={
"fill-extrusion-color": ["get", "color"],
"fill-extrusion-height": ["get", "height"],
"fill-extrusion-base": ["get", "base_height"],
"fill-extrusion-opacity": 0.5,
},
)
m.add_layer_control()
m
In [ ]:
Copied!