42

I have a shapefile with contours and their heights.

Is it possible to make a DEM from contours in QGIS without using GRASS?

I found Creating DEM from contours using ArcGIS Desktop? but the answer is for ArcGIS Desktop.

0

5 Answers 5

30

Yes, there are several options available in QGIS:

  1. Inverse Distance Weighting (IDW) Interpolation plugin - see this for a tutorial (archived from the original).
  2. GDAL Raster plugin - to access, click Raster > Grid (Interpolation). GDAL's interpolation is more robust because you can use other interpolation algorithms (IDW, nearest neighbor, moving average, etc.). This tools only works for point data.
  3. GRASS GIS Plugin - there are several modules you can use (v.surf.* and r.surf.*). You need convert your shapefile into a GRASS database to use the GRASS modules in QGIS.
7
  • Are you sure, because when I execute your second suggested procedure, with GDAL Raster, it shows me this error message: "No point geometry found on layer modashp, skipping."
    – Vassilis
    Commented Dec 21, 2011 at 11:00
  • I updated the answer that it only works for point data. You can also look at GRASS GIS which has plugin in QGIS.
    – maning
    Commented Dec 21, 2011 at 11:27
  • 3
    The QGIS Interpolation plugin works olso with contour lines: add the attribute that holds the value to interpolate then in "type" select "structured lines" or "break lines"
    – gioman
    Commented Dec 21, 2011 at 12:30
  • 8
    IDW is inappropriate for contour line data. When forced to work with them, it will produce awful DEMs (they will look like terraces). Nearest neighbor and moving averages have similar problems. Interpolating rasters from contour lines requires specialized methods.
    – whuber
    Commented Dec 21, 2011 at 17:54
  • @whuber - any hints on these specialized methods? Seem to be getting OK results with inverse-distance-to-a-power in the Raster|Grid (Interpolation) tool, but definitely not perfect!
    – Simbamangu
    Commented Dec 23, 2011 at 6:58
12

GRASS has also many options

http://grass.osgeo.org/wiki/Contour_lines_to_DEM

available one way or another also trough the QGIS/GRASS plugin.

3
  • Didn't the question specifically exclude GRASS? (You might want to rethink your comment to the reply by @jdeltoro.) Nevertheless, if a good solution is not available in QGIS, it is wise to cast one's net wider, so it's good to know of alternative solutions.
    – whuber
    Commented Dec 23, 2011 at 13:48
  • 2
    It depends what does mean "without using GRASS". This because many people do not know they can use GRASS tools inside QGIS like any other QGIS tool, without knowing at all what GRASS is or how it works.
    – gioman
    Commented Dec 23, 2011 at 14:07
  • Yes, for a small tutorial see grass.osgeo.org/wiki/QGIS_GRASS_Cookbook
    – markusN
    Commented Dec 28, 2011 at 0:50
9

I just posted this answer on another thread that was asking the same question. This is by far the easiest method that I have found.

I had the same question and looked everywhere! Finally a solution - you need to use "TIN interpolation". This video explains it perfectly: https://www.youtube.com/watch?v=PhJ77uHlTJA

It demonstrates other processes as well but the main thing is they used contour line data and created a DEM. Really good explanation as well.

Key tools used:

  • TIN interpolation (Processing Toolbox)
  • Slope (you can skip this one)(Processing Toolbox)
  • Hillshade (Raster tab)
1
  • 2
    +1. After trying several methods, TIN interpolation was by far the easiest and produced the cleanest result. IDW interpolation from points tended to create terracing in the DEM, and using v.to.rast and r.surf.contours can only handle small areas without crashing. Commented Oct 30, 2020 at 5:01
2

The question is old, but as it is ranked high in Google search, so I think it is helpful to say QGIS has built-in interpolation tools:

https://www.qgistutorials.com/en/docs/interpolating_point_data.html

However, the tutorial is also old.

For QGis 3.2, you can find it in the PROCESSING TOOLBOX, or in the RASTER > ANALYSIS > GRID menu:

enter image description here

enter image description here

2
  • Hei marcos, do you have any ides which interpolation is the best for contours(moving average, nearest neighbour or any other from those four?)
    – Usha
    Commented Dec 9, 2022 at 11:29
  • @Usha, I don't know, because I didn't study the way each one works. When I need some interpolation, I do trial and error. But I'm sure some methods are better for some uses than others. Commented Feb 23, 2023 at 15:29
0

MiraMon has an excellent tool for converting contour lines (and supports adding breaklines as ridges, channels (2D or 3D) or roads (3D)) to a raster using an optimum algorithm for that.

You can download the package for free from www.miramon.cat. The module (IsoMDE) is available via "Tools | Terrain interpolation and analysis | Interpolation from contour lines".

MiraMon v.9 can import many formats and from v. 10 < https://www.miramon.cat/mus/eng/index_10.htm > any vector format via GDAL/OGR (in fact, GDAL has a MiraMonVector driver also). The generated DEM (in IMG format) can be exported via TIFF, ASCII, etc.

All processes can be also executed from command line (see syntax at the help system, or generate commands from the "BAT/PS1" button of any module).

More info at https://www.miramon.cat/help/eng/msa/IsoMDE.htm

2
  • 1
    This reads like spam. Please add a disclaimer if you are associated to this product.
    – MrXsquared
    Commented Nov 17 at 20:29
  • Disclaimer: Obtaining a DEM from contour lines is not particularly well solved in general: Interpolating from the vertices of lines loses the spatial nature of the contours, and TIN also has other drawbacks too long to be covered here; Douglas already drew attention to the need of specific algorithms, more than 20 years ago. We published a paper that can be downloaded at ResearchGate (look for IsoMDE). The question was asked in a general GIS forum and, just to be helpful, I suggested the free and scriptable tool derived from that research :- ) Commented Nov 18 at 22:18

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