I have difficulties generating 3D contour lines from a raster file in QGIS. It's a tif raster of an elevation model that I exported from a professor's ArcGIS project. I want to create contour lines in order to import them into SketchUP to design some engineering biological measures. Every time I use the Raster>Extract>Contours command, I only get 2D lines. I've already checked old forum entries and tried a couple of solutions, but so far nothing's worked out.

What could the problem possibly be?


You only need to extract Z-values from your raster, and attach them to the contour lines you have just obtained.

(1) You have a raster and contour lines. (Make sure you have elevation attribute like ELEV in your line shapefile). enter image description here

(2) Next, activate GRASS v.drape which you can find in the Processing Toolbox GRASS GIS 7 | Vector.

enter image description here

  • Input vector layer : Your contour layer.
  • Elevation raster... : Your raster.
  • WHERE conditions of SQL... : You cannot leave it blank. Hence please add any conditions you can think of. In this case I set "ELEV" < 100 so that I can select everything.
  • Vector Z for unknown height: I set 1000 which was reasonably out of my value range.

(3) Running this will produce a new line layer named 3D vector. You can check it by Identify Features tool, which gives you Closest vertex Z information.

enter image description here

(4) Do not forget export the (3D vector) as a new shapefile. Default setting will automatically keep the Z-dimension, but it is still better to double check Geometry type while saving.


enter image description here

Just to add; if you import the 3D-contour and your raster into SAGA GIS, you can use 3D viewer to visually check your output.

  • You, Sir or Madam, have seriously saved my life! Thank you so much! I had some initial troubles installing GRASS on my Mac, but now it all worked out. :) – vindobonensis Jan 28 '18 at 14:01
  • @vindobonensis It's my pleasure. Good luck with your project! – Kazuhito Jan 28 '18 at 16:38

Try using QGIS 3.0, and run the contour algorithm. Check under advanced options and tick "Produce 3D vector".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.