Visualizing 3D data with expressions

How to visualize point data with Z values? Let’s say: we have data about noise pollution in multi-storey buildings. The point data (apartments) looks like this:

selection_005The attribute table looks like this:

selection_004We see X and Y coordinates, and a Z (height) value. The DB column gives the actual noise data, which we want to visualize. How to do this?

One idea was to use diagrams. QGIS, however, gives only pie charts and histograms, which don’t satisfy in my case.

Another idea was the Point Displacement option in the styling of the layer. This didn’t work out well either, because I couldn’t arrange the points properly. I wanted to place them above each other, with the highest Z value on top.

The idea that did work out was to use Offset X,Y in the Symbol selector:

symbol-selector_007Using this, you can offset the marker symbols in horizontal (X) and vertical (Y) direction. Instead of just using X and Y values, you can also use an expression. Using an expression, you get the possibility to use values in the attribute table for changing the X and Y offset value for each point. That gave me the solution!

After a lot of trying I used this expression:

‘0, ‘|| to_string(-1 * “z”)

Let me explain. “z” is the height value I want to use. A positive Z value gives the marker a downward offset. I want it upward, so I took the negative of Z. Because the result of the expression has to be a string value, I used the to_string expression to do so. Because the expression changes both X and Y, and I didn’t want to change the X value, I used ‘0, ‘ in the beginning of the expression, and concatenated (||) the 2 expressions.
Here’s the result:

qgis-2-14-11-essen-verschovenpuntenmetexpressies_010Now you see all apartments in the different blocks: the markers at the bottom are the lowest in the block, at the top are the highest apartments. There are some gaps, because the data were incomplete. The small blue points indicate the original X and Y coordinates.

The possibilities of these expressions are myriad. And with adding text labels, you can use these expressions too, to place them exactly where you want (in the markers, beside the markers, whatever).

Good luck!

Published by

Willem Hoffmans

GIS expert met inhoud

One thought on “Visualizing 3D data with expressions”

  1. Thank you for sharing this useful trick!
    I was labeling through several duplicates of the same layer at different offset positions, so this was an excellent suggestion for using a single layer.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>