I am looking to create 3D terrain from a contour map that I have (originally inside a PDF). The contour lines are able to be viewed as paths in Adobe Illustrator. There are two types of lines: 7m and 2m intervals, which are the same color, but have different weights (the 7m contour lines are twice the weight of the 2m contour lines). If it might be useful to know: according to its metadata, the PDF appears to have been exported from AutoCAD. The contour lines (as paths in Illustrator) can be exported as .DXF, .DWG, and several other formats.

What is the simplest/easiest way to create a 3D model with the available data? Can it be done with free/open source software?

I can't seem to find anything that matches my situation.




I'm looking to create a 3D representation from the contour lines in order to render it in a 3D modelling program - something like a .DAE format (or similar).

The (near to) end result will look like:


  • You can export the vertices of the lines gis.stackexchange.com/questions/72673/… with elevation then use GDAL_Grid gdal.org/gdal_grid.html to convert the irregular points into a DEM... Commented May 5, 2015 at 1:41
  • What is you ultimate goal? What you want to achieve will determine the approach and software. There is a 3D data viewier called NVIZ in GRASS (and therefore available in QGIS) and that might be all you need after exporting the contours. Alternatively you may want to achieve something more sophisticated. Again, it migt be that you don't need a 3D viewer at all if you want to perform some calculations (e.g. line of sight, viewshed, flow accumulation etc). So please can you edit your question to provide more information. Commented May 5, 2015 at 5:48
  • @MappaGnosis Thank you for your reply. I've updated my question.
    – Afonso
    Commented May 5, 2015 at 6:15
  • @MichaelMiles-Stimson Thank you for your reply. I'm new to QGIS/GIS, so I don't quite follow your reply. At the moment I've gotten the contour lines out of the PDF (with line weights intact - 7M and 2M). While all the contour lines can be successfully imported into QGIS, they don't keep their line weights. I can export the contour lines from Illustrator as a raster image (PNG, for example) which will maintain the proper line weights, but I'm not sure if that's a good idea or not.
    – Afonso
    Commented May 5, 2015 at 6:38
  • 1
    Never mind the 2m/7m distinction, how do you know the height of each contour line?
    – Spacedman
    Commented May 5, 2015 at 8:29

1 Answer 1


If you export the lines as DXF, you should be able to load them into QGIS. Once they are in QGIS, you need to create an attribute that contains the elevation of each line (ie. a data column with a number). Depending on the total number of lines you could possibly do this manually.

If doing it manually is not an option, you could concievably do some Python sorcery to iterate through the lines in some intelligent way to calculate the elevation. However, the best scenario would be if you could get the contours as proper geodata with 3D coordinates from the person who originally created the PDF.

When you have the contours prepared with an elevation attribute (or 3D coordinates if you could get them from the source), you can use the interpolation tool in the raster menu in QGIS to turn them into a heightmap raster. After that you can use that raster as a displacement map in your 3D-modelling software. You can have a look at this tutorial for Blender for that part if you are new to it:


As the tutorial also mentions, there is a Blender plugin to directly import a heightmap raster and turn it into a 3D-surface as well.

Note that I'm assuming you're not interested in keeping the original geographic coordinate system, but just want a model for visualisation.

  • Thank you for your answer. There are about 1700 lines, so it would have to be automatic. Python sounds like the way to go. Do you know if a DXF file stores lineweights (so I can add a height attribute to it - 7m or 2m)? I was looking through the DXF file specification (this one: images.autodesk.com/adsk/files/acad_dxf0.pdf), and I can't seem to see a way to determine weight - I'll keep looking. As for the original geographic coordinate system, I'm not entirely sure what it is - the PDF only contains a distance scale, a note regarding line weights, and the contour lines themselves.
    – Afonso
    Commented May 6, 2015 at 9:31
  • As I understand it, DXF does not store lineweight, but I might be wrong here. If you could make two exports, one where you have deleted the 7m lines, and another where you have deleted the 2m ones, you could at least separate them in two files.
    – hexamon
    Commented May 8, 2015 at 11:25
  • You should also dig around in the PDF to see if there is some hidden attribute that gives the exact elevation for each contour line, since it would make things much simpler.
    – hexamon
    Commented May 8, 2015 at 11:35
  • That's a good idea re: separate files. I looked around the PDF file (e.g. attachments, layers, etc), and there doesn't seem to be anything that could be used for contour height. I guess I'll have to see if I can get the original data.
    – Afonso
    Commented May 10, 2015 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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