A tutorial in pictures: 3D hexagons in QGIS

3 min read

This mini-tutorial is a work in progress and I have documented it during #30DayMapChallenge 2021 on Twitter, when I was preparing day 5, hexagons. I have repeated the process several times, so I needed a way to remember the steps. So here it is: rendering hexagons from a DEM resulted from LiDAR data in #Threejs using #QGIS and #Qgis2threejs.

You can also find it on Twitter and if you want to use only QGIS, Klas Karlsson has made a similar tutorial on using the 3D renderer, and can be found on YouTube.

I will add more detailed explanations , but until then below is the speed tutorial version. 🙂

Yesterday I have derived hexagons from a DEM resulted from LiDAR data, and rendered them in #Threejs using #QGIS and #Qgis2threejs. Here’s the process, so that I(you) don’t have to repeat it a thousand times to succeed. 😀

Create a polygon layer and draw a hexagon, then export the raster pixels that intersect it using a layer mask.

Create a hexagonal grid with the horizontal and vertical spacing of 50m, using the extent from the clipped raster, and update the polygons with the maximum height value from the initial raster pixels, using Zonal statistics.

Create a new ‘rel_height’ field and update it with the minimum height value from the raster, filter the grid to exclude the cells without values, and export the filtered cells.

Rasterize the filtered layer (‘rel_height’ for burn-in value, 0.5 for horizontal and vertical resolution, ‘Georeferenced units’ as output units, and the extent from the filtered layer), then style the resulted raster to examine it.

Use Qgis2threejs to setup and export the scene to the web. First, increase the resampling level and add edges to highlight the hexagons.

Then add a new layer to #QGIS, #OpenStreetMap tiles, set the filtered layer general opacity to 0 to allow #Qgis2threejs to pick up the background colors, export the scene to web with the option ‘Enable the viewer to run locally’ checked, and view the result in the browser.

Leave a Reply

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