This tutorial explains how to create 3DTiles from Open Street Map data. In this example, we create 3DTiles of the buildings of Lyon.
This tutorial is based on Delft University of Technology's tutorial.
Go on OpenStreetMap website.
Click on Export
(top left of the screen) to open the export panel.
Go on the area you want to download and export it by clicking on Export
on the left.
If the area is to big to be downloaded by OpenStreetMap, select Overpass API
. This will download the data from a miror of the database.
A file called map
or map.osm
should be downloaded.
In the previous step, you have downloaded an OSM file. To be able to create the 3DTiles, we need to extract the buildings as a GeoJSON file.
Open the OSM file in QGIS (by drag&dropping it in a QGIS project or with Layer > Add layer > Add vector layer
).
Import only the Multipolygons
layer, this layer contains the buildings.
Right click on the layer on the Layers
panel and select Filter
. Write the expression "building" is not null
and click OK. This will keep only the buildings.
Only the buildings should be present in your QGIS project now.
Known issue: OSM data doesn't handle holed polygons properly. To fix the holed polygons, export your buildings as ESRI Shapefile
then open the shapefile in QGIS. Use this new layer in the next steps.
Export the buildings as GeoJSON in EPSG:2154 and choose a name for your file.
A GeoJSON file of the choosen name will be downloaded.
First, install py3dtilers. The Geojson Tiler will be used to transform the GeoJSON file into 3DTiles.
Once the installation is completed, run the Geojson Tiler:
geojson-tiler --path path/to/osm_buildings.geojson --z 0 --height 6
--path
specifies the path to the file to transform.--z
allows to choose the altitude of the features. Here, we choose 0 m.--height
adds an height to the buildings. The height is 6 m in this case.
If you want to project your 3DTiles into another CRS, you can choose the input and output CRS with --crs_in
and --crs_out
flags:
geojson-tiler --path path/to/osm_buildings.geojson --z 0 --height 6 --crs_in EPSG:2154 --crs_out EPSG:4978
The 3DTiles are created in a directory called geojson_tilesets. To visualize this tileset in Cesium, iTowns or UD-Viz, see how to visualize 3DTiles.