Intro to QGIS3 3D view with Viennese building data

In this post, I want to show how to visualize building block data published by the city of Vienna in 3D using QGIS. This data is interesting due to its level of detail. For example, here you can see the Albertina landmark in the center of Vienna:

an this is the corresponding 3D visualization, including flying roof:

To enable 3D view in QGIS 2.99 (soon to be released as QGIS 3), go to View | New 3D Map View.

Viennese building data (https://www.data.gv.at/katalog/dataset/76c2e577-268f-4a93-bccd-7d5b43b14efd) is provided as Shapefiles. (Saber Razmjooei recently published a similar post using data from New York City in ESRI Multipatch format.) You can download a copy of the Shapefile and a DEM for the same area from my dropbox.  The Shapefile contains the following relevant attributes for 3D visualization

  • O_KOTE: absolute building height measured to the roof gutter(?) (“absolute Gebäudehöhe der Dachtraufe”)
  • U_KOTE: absolute height of the lower edge of the building block if floating above ground (“absolute Überbauungshöhe unten”)
  • HOEHE_DGM: absolute height of the terrain (“absolute Geländehöhe”)
  • T_KOTE: lowest point of the terrain for the given building block (“tiefster Punkt des Geländes auf den Kanten der Gebäudeteilfläche”)

To style the 3D view in QGIS 3, I set height to “U_KOTE” and extrusion to

O_KOTE-coalesce(U_KOTE,0)

both with a default value of 0 which is used if the field or expression is NULL:

The altitude clamping setting defines how height values are interpreted. Absolute clamping is perfect for the Viennese data since all height values are provided as absolute measures from 0. Other options are “relative” and “terrain” which add given elevation values to the underlying terrain elevation. According to the source of qgs3dutils:

  AltClampAbsolute,   //!< Z_final = z_geometry
  AltClampRelative,   //!< Z_final = z_terrain + z_geometry
  AltClampTerrain,    //!< Z_final = z_terrain

The gray colored polygon style shown in the map view on the top creates the illusion of shadows in the 3D view:

 

Beyond that, this example also features elevation model data which can be configured in the 3D View panel. I found it helpful to increase the terrain tile resolution (for example to 256 px) in order to get more detailed terrain renderings:

Overall, the results look pretty good. There are just a few small glitches in the rendering, as well as in the data. For example, the kiosik in front of Albertina which you can also see in the StreetView image, is lacking height information and therefore we can only see it’s “shadow” in the 3D rendering.

So far, I found 3D rendering performance very good. It works great on my PC with Nvidia graphics card. On my notebook with Intel Iris graphics, I’m unfortunately still experiencing crashes which I hope will be resolved in the future.

33 comments
  1. Hello, I have to recover well the data and follow-up your instructions but:

    1. I do not see appearing in the data line DIFF_O_U: difference between O_KOTE and U_KOTE

    2. Don’t I have pas de returned 3D of the layer of construction???

    3. Is this a problem of graphic card? I use version 2.99 of QGIS. Thank you for your answer. Maths

    • You can compute DIFF_O_U using the expression O_KOTE-coalesce(U_KOTE,0).

      I don’t understand your second question, sorry. Feel free to post in French and I’ll try my luck with Google translate.

      • Oui désolé pour cette très mauvaise traduction. Le problème est que je ne parviens pas à avoir un effet 3 D. J’ai pourtant téléchargé la version 2.99 de QGIS et suivi vos instructions. Mais je n’ai pas d’effet 3d. Je dois faire une erreur quelque part.
        Merci pour votre repone.

        Math

      • Merci beaucoup. Je vais à nouveau faire la manipulation à partir de vos données. Je vous tiens au courant et vous remercie encore d’avoir pris la peine de me répondre. Math.

      • Je viens d’essayer à nouveau avec vos données mais je n’ai toujours pas l’effet 3D.

        1. Je mets la hauteur sur U_KOTE à l’aide de l “Assistant”

        2. Je mets l’extrusion sur DIFF_O_U à l’aide de l'”Assistant”

        Mais rien ne se passe ??

        Est-ce un problème lié à une mauvaise manipulation, de version de la 2.99 ou de carte graphique ??

        Encore merci pour votre aide.

        Math

      • Can you provide a few screenshots? It’s hard to guess what might be wrong. When did you last update your 2.99 install? (Mine is 2 days old.)

      • Re-bonjour,

        Je viens donc d’installer cette version de QGIS 2.99 :

        http://qgis.org/downloads/weekly/?C=M;O=D

        Mais je n’ai toujours pas de 3D sur ma couche de construction.

        J’ai plusieurs captures d’écran mais je ne sais pas comment les insérer ici.

        Math

      • Those size assistant settings don’t look right to me and you don’t need it. Instead, set the value directly as shown here:

        Use the middle mouse button to tilt the camera in 3D view so you can actually see the results.

      • Une autre capture d’écran où j’ai bien essayé de jouer avec la molette de la souris et fait varier l’orientation…

      • Bon, je vais d’essayer avec un autre ordinateur et cela semble fonctionné…mais la partie supérieure. Est-ce normal ?

        Bonne fin de journée et encore merci.

        Math

      • Looks good.

      • Merci beaucoup pour votre aide votre grande patience.
        Au plaisir de vous lire…J’ai déjà appris beaucoup de choses avec vos ouvrages dont qgis_map_design.

        Bonne fin de soirée,

        Math

  2. On my notebook with Intel HD Graphics 5500 it mostly crashes when enableing the 3d renderer for the building shapes. Only when the notebook is restarted and I start qgis the first time, then it works…but thanks for that example. Would you mind, if I use your example in a qgis3 workshop?

  3. Hi Anita, Following your steps above (for the Vienna shp not DEM) Q crashes every time. I’m on 2.99 (08d27630ea) 3 days old.

    Here’s the crash report:

    *Crash ID*: 5bf10352ae4074da4522f52a411c22f3b5784af7

    *Stack Trace*

    DrvGetLayerPaletteEntries :
    DrvGetLayerPaletteEntries :
    DrvGetLayerPaletteEntries :
    DrvGetLayerPaletteEntries :
    DrvGetLayerPaletteEntries :
    DrvGetLayerPaletteEntries :
    Qt3DRender::Render::Renderer::performDraw :
    Qt3DRender::Render::Renderer::executeCommandsSubmission :
    Qt3DRender::Render::Renderer::submitRenderViews :
    Qt3DRender::Render::Renderer::doRender :
    Qt3DRender::Render::Renderer::render :
    Qt3DRender::Render::NodeManagers::renderTargetManager :
    QThread::start :
    BaseThreadInitThunk :
    RtlUserThreadStart :

    *QGIS Info*
    QGIS Version: 2.99.0-Master
    QGIS code revision: commit:08d27630ea
    Compiled against Qt: 5.9.2
    Running against Qt: 5.9.2
    Compiled against GDAL: 2.2.3
    Running against GDAL: 2.2.3

    *System Info*
    CPU Type: x86_64
    Kernel Type: winnt
    Kernel Version: 6.3.9600

    Any suggestions appreciated. Cheers, Oliver

    • Please add your crash info to the linked bug report where devs can have a look at it.

  4. Umberto said:

    Hi underdark,
    very promising feature!
    I am experiencing the same crash as some of the users here.
    I opened a issue here.
    https://issues.qgis.org/issues/17788
    Hope they’ll fix it!
    great post though, thanks for sharing!

    • Umberto said:

      In the newer version (using 3.0.1-Girona) with the same computer/project/data, this problem now seems to be fixed. I commented in the QGIS bug report at https://issues.qgis.org/issues/17315.

      • Great to hear! Thanks

  5. robert kalasek said:

    nice demo …
    sice assistant provides strange results – indead.
    … had a look into the viennese data and the figuered out that the following settings provide correct results concerning base height (dhm), lower (u_kote) and upper (o_kote) height of objects

    Height:
    CASE
    WHEN “u_kote” > “hoehe_dgm” THEN “u_kote”
    ELSE “hoehe_dgm”
    END

    Extrusion:
    CASE
    WHEN “u_kote” > “hoehe_dgm” THEN “o_kote” -“u_kote”
    ELSE “o_kote” – “hoehe_dgm”
    END

    best robert

    • Great! Thanks for sharing, Robert!

  6. mnahmad said:

    Hi

    I installed QGIS 3.0 on 28th using qgis.org/ubuntugis-nightly-release repository on Ubunut 16.04. Some how I cannot see the option “New 3D map view” in view menu.

    thanks

    • The necessary dependencies are only available if you used the ubuntugis packages

      • mnahmad said:

        Thanks for quick reply