I am generating contour lines from a DEM using QGIS and the python console. The process generates many small circles in regions of low slope (little black circles) that detract from the long connected contour representing the "true" contour (indicated by hand in blue) in the picture.

low slope contour artifacts

As suggested "https://community.esri.com/thread/206552-isyhypses-filtering-out-very-small-areas-of-elevation" I could filter the contour lines for length but that may also remove many "true" contours that can be seen in my attached image such as the few small hills here and there (indicated by hand for example in red).

Google searches suggest to smooth the underlying source DEM as in smoothing DEM but that would reduce the quality of the generated contour lines.

The best idea I had, would be to somehow boolean filter the contour lines against length as described above AND/OR local slope % as described calculating-slope-in-percentage-with-qgis, but I haven't yet determined how or if this is possible in pyQGIS - possibly by calculating a slope % tif and then reading it at every vertex of each contour then averaging for each contour feature to create a second attribute to boolean filter along with length. Before I embark on that (probably time consuming) solution, is there an existing method for removing the low-slope artifacts generated in the DEM to contour process available in pyQGIS?

Edit: image added to indicate results of resampling (1s blue, 18s green, 27s red, underlying DEM 1 arc second) enter image description here

  • 4
    Have you tried resampling your DEM as Google suggests? The result might surprise you; quality of a nonexistent entity is entirely subjective, you either like or don't like the result based on aesthetics more than location.. Try GDAL_Translate with -r cubicspline or lanczos and perhaps go for a bigger cell size to try to suppress the noise. Similar to gis.stackexchange.com/questions/94858/how-to-clean-up-contours/… but QGIS oriented. Apr 25, 2018 at 0:43
  • Thanks tto @Michael I ended up comparing results from 1second of arc, 18 s and 27s using GRASS r.resamp.bspline and found that I could get satisfactory results. I may not even bother with filtering out the little circles left. I've added a picture of the comparison to my question for other to see.
    – Mr Purple
    Apr 25, 2018 at 9:21
  • 1
    See also: gis.stackexchange.com/questions/276897/…
    – Stefan
    Apr 25, 2018 at 9:28
  • Ah @Stefan I didn't find that in my searches. While the specific artifacts (circles at low slope) differ in the question *slightly, the answer is clearly applicable. Cheers.
    – Mr Purple
    Apr 25, 2018 at 9:42


Your Answer

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

Browse other questions tagged or ask your own question.