Making elevation contours of raster smoother using QGIS

In my case, I have a DEM with continue values, going from 100 to 103 meters. The spatial resolution is 0.25 x 0.25 degrees, defined in EPSG:4326. The DEM is styled with a discrete color ramp with three classes:

1


To smooth it, first I will make a raster algebra. Because I want a raster with only three values. I am using the following formula:

("testDEM@1"  <= 100) * 100 +
("testDEM@1"  > 100  AND  "testDEM@1" <= 101) * 101 +
("testDEM@1" > 101 AND "testDEM@1" <= 103) * 103

2

Don't worry about its style, because it is an intermediate step:

3


For the smooting, I will use GRASS provider r.resamp.rst algorithm, in two steps. First, we need the slope output to use it as a smoothing raster. So run the algorithm without smooth raster. Set the spatial resolution and delete row/column overlap and spline tension values:

4

From the outputs, I have removed all of them except the slopes raster:

5


Finally, run the GRASS provider r.resamp.rst algorithm again, defining the slopes output as smoothing raster:

6

We just need the Resampled output. But now, we will style it with a linear interpolation instead discrete:

7


Now, you can use that raster with a 65% transparency over a hillshade:

8


External Reference:

  • https://grass.osgeo.org/grass79/manuals/r.resamp.rst.html

There are several tools that exist in qgis to smooth contour lines as opposed to smoothing the raster itself , including vector->geometry->simplify, the vector geometry tool "smooth", and the GRASS function v.generalize.

Personally, I like the results of the SAGA module line smoothing ("http://www.saga-gis.org/saga_tool_doc/2.2.2/shapes_lines_7.html), and the results in the sample data I used look pretty similar to what you provided.

To use it, make sure you have the SAGA installed (https://sourceforge.net/p/saga-gis/wiki/SAGA%20Installation/) then select the tool from the processing toolbox (#1). Use the method drop-down menu to select the improved iterative averaging (SIA) algorithm (#2).

instructions

Before:

before

After:

after

You can then convert the lines back to raster format via GRASS package's r.surface.contour or similar. Creating a contour raster from contour lines shapefile