loader image
メインコンテンツへスキップする

2. Preprocesssing data

2.2. Extrude buildings

The buildings that we've downloaded from OpenStreetMap have attributes that we can use for their height:

  • height
  • building:levels, which is the amount of floors

Not all buildings have these values and the values are sometimes noted with their units. This makes it a lot of work to clean up the data.

Therefore, here we're going to use the elevation from the DSM to add the Z attribute to the building polygons.

1. In the Processing Toolbox open the tool Raster analysis | Zonal statistics.


2. In the Zonal Statistics dialog, choose the buildings layer as Input layer and DSM_Rotterdam as Raster layer. Type for Output column prefix Z_, so the field will be easy to recognize. For Statistics to calculate only choose the Mean. In that way each building polygon will get the mean value from the overlapping pixels in DSM_Rotterdam. Save the result in the  existing GeoPackage with the name buildings with height.


3. Click Run. Click Close after processing has completed.

4. Make sure that in the Layers panel, this layer is at the top of the Flood analysis group and that below the DTM_voidsremoved layer is visible.

Now let's check the result in the QGIS 3D View.

5. Save the project.

6. Go to the Layer Styling panel and make sure that the buildings with height layer is active.

7. There go to the 3D View  tab where we can set the 3D visualization properties.

8. Set the renderer to Single Symbol.

9. At Extrusion, click  to set a data-defined override.

10. Select Field type and choose the Z_Mean field.


11. Make sure that the other settings are the same as in this screenshot:


Now we're ready to check our buildings in 3D.

12. From the main menu, select View | 3D Map Views | New 3D Map View.


13. In the new 3D map view, click  and choose Configure....

14. In the Terrain tab change Type to DEM (Raster Layer) and choose DTM_voidsremoved for Elevation. In this way the DTM elevation values will be used to visualize the DTM. The buildings will be shown on top. Change the Tile resolution to 512 px to see more detail.


15. Click OK.

Wait until the 3D view renders.


Now we can see the 3D buildings on top of the terrain.