Creating Isometric Buildings (QGIS3)

Contributed by: Steven Kim

OpenStreetMap (OSM) is a crowd-sourced global dataset of roads, boundaries, buildings and more. It has a growing collection of building footprints across the world with many of them also having height information. While the accuracy of building height data is notoriously difficult to validate for analysis, we can use QGIS expressions to create a fun artistic isometric rendering from this data.

Overview of the task

We will download building footprints data from OSM for downtown Toronto and create an isometric map of building heights.

../../_images/output2.png

Get the data

We will be downloading data from OpenStreetMap(OSM) using the QuickOSM plugin. See Căutarea și descărcarea datelor OpenStreetMap (QGIS3) for an introduction to the QuickOSM plugin. Once you have installed the plugin, you can proceed with the instructions below to obtain data for your region.

Notă

This tutorial is specifically designed to work with the OSM data extracted from the QuickOSM plugin. The height expression does not work with OSM planet files or data extracts with other_tags. In those cases you first need to extract building levels and heights before using them.

  1. Open QGIS. We’ll first load a basemap. From the Browser panel, scroll down and locate XYZ Tiles ‣ OpenStreetMap tile layer. Drag and drop it to the main canvas. Zoom to your region of interest. Make sure the region is fully covered by the map extent.

../../_images/data115.png
  1. Launch the QuickOSM plugin from Vector ‣ QuickOSM ‣ QuickOSM….

../../_images/data25.png
  1. In the Quick query tab, enter building as the Key. Change the In to Canvas Extent. This will download all buildings in the current canvas extent. Expand the Advanced section, then unclick Points, Lines and Multilinestrings. This should leave Nodes, Ways, Relations and Multipolygons selected. Select Run query. Close the window once the map is loaded.

../../_images/data35.png
  1. All the available building footprints in the canvas extent will be loaded in a new layer building. You can continue with the data, or select a subset of the buildings. For this tutorial, we will select all buildings in your region of interest. Click the Select Features by Area or Single Click button on the Selection Toolbar. You can hold the left mouse button and draw a rectangle to select the required buildings. You can also hold the Shift key and click on the polygons to select them.

../../_images/data45.png
  1. Once all the required buildings are selected, right click the building layer and select Export ‣ Save Selected Features As….

../../_images/data54.png
  1. In the Save Vector Layer As… dialog, click the button next to File name and browse to a folder on your computer. Enter the File name as osm_buildings.gpkg and Layer name as buildings. The downloaded buildings are in the CRS EPSG:4326 WGS84. This is a Geographic CRS with units in degrees. We can choose a Projected CRS which will allow us to use linear units of measurement such as meters. Click the dropdown menu for Select CRS and choose Project CRS: EPSG:3857 - WGS84 / Pseudo-Mercator. Click OK.

../../_images/data64.png
  1. The selected buildings will be reprojected and saved to a new geopackage file.

../../_images/data74.png

For convenience, you may directly download a copy of the downtown toronto buildings from below:

osm_buildings.gpkg

Data Source [OPENSTREETMAP]

Procedure

  1. Locate the osm_buildings.gpkg file in the QGIS Browser and expand it. Select the buildings layer and drag it to the canvas.

    ../../_images/1106.png
  2. Click on Open Layer Styling Panel and switch from Single Symbol to 2.5 D.

    ../../_images/2102.png
  3. Click the ε button next to Height.

    ../../_images/340.png
  4. In the Expression Builder, enter the following expression. This expression applies a multiplier to the first non-null field from building:levels and height. If both are null, then a default height of 20 meters is used. Keep in mind these are exaggerated heights for visualizing at larger scales.

coalesce("building:levels"*10, "height"*2, 20)
../../_images/423.png
  1. Change the Angle to 135 degrees.

    ../../_images/520.png
  2. Un-check the Shade walls based on aspect and Shadow. We will be appling our own colors. Click on the dropdown for selecting the renderer.

    ../../_images/620.png
  3. Change from 2.5 D back to Single Symbol.

    ../../_images/719.png
  4. In the Symbol window, notice there are two Geometry Generators, each with a Simple Fill layer type. The first Simple Fill is the top face of each block, whereas the second Simple Fill is the side face. Click on the first Simple Fill to change the color of the top face. Click on Data define override button for the Fill color and select Edit… on the menu.

    ../../_images/819.png
  5. This brings up the Expression Builder dialog for Fill color. Enter the following expression. This expression applies the Spectral color ramp to the data based on its distance from the map center.

ramp_color('Spectral',
    scale_linear(
        distance(@geometry,@map_extent_center),
        0,@map_extent_width/6,
        0,1
    )
)
../../_images/919.png
  1. Click on Data define override button for the Fill color and select Copy… on the menu.

    ../../_images/1025.png
  2. Click on Data define override button for the Stroke color and select Paste… on the menu to apply the same expression.

    ../../_images/1128.png
  3. Now click on the second Simple Fill to change the sides. You may have to scroll down to do this. Click on the dropdown menu for the Symbol Layer Type.

    ../../_images/1226.png
  4. Change the Symbol Layer Type from Simple Fill to Gradient Fill. The two color selectors beside the Two color represent the top and bottom colors of the gradient. Click on Data define override button for the top color.

    ../../_images/1324.png
  5. Select Edit and enter the following expression. This is the same expression that we used for the roof color but adjusts the transparency of the color using the set_color_part() function.

    set_color_part(
      ramp_color('Spectral',
          scale_linear(
              distance(@geometry,@map_extent_center),
              0,@map_extent_width/6,
              0,1
          )
      ), 'alpha',100)
    
    ../../_images/1422.png
  6. Click on the small black triangle of the bottom color selector and check Transparent box.

    ../../_images/1519.png
  7. Before exiting the Layer Styling Panel, let’s transform the layer to complete the isometric look. Expand the Layer Rendering section and check Draw Effects. Click on the Customize Effects star on the right.

    ../../_images/1618.png
  8. Click on the dropdown menu next to Effect Type.

    ../../_images/1719.png
  9. Change the Effect Type from Source to Transform. For Shear X,Y, enter -0.2 and -0.2 respectively.

    ../../_images/1816.png
  10. Enter 45 for Rotation. Exit and close the Layer Styling Panel.

    ../../_images/1913.png
  11. You should see a colorful representation of building polygons in isometric view. Feel free to experiment with the expressions for height, angle, fill colors and so on.

    ../../_images/2013.png

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)