19

We have just received a large set of DEMs at work and I would like to generate contours from them. The DEMs have a resolution of 1m and a size of 1kmx1km.

Output from gdalinfo:

Driver: AAIGrid/Arc/Info ASCII Grid
Files: 380000_6888000_1k_1m_DEM_ESRI.asc
Size is 1000, 1000
Coordinate System is `'
Origin = (380000.000000000000000,6888000.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Corner Coordinates:
Upper Left  (  380000.000, 6888000.000)
Lower Left  (  380000.000, 6887000.000)
Upper Right (  381000.000, 6888000.000)
Lower Right (  381000.000, 6887000.000)
Center      (  380500.000, 6887500.000)
Band 1 Block=1000x1 Type=Float32, ColorInterp=Undefined
  NoData Value=-9999

I know I can use gdal_contour to generate the contours (my blog post on the topic) but I'm wondering what some best practices for generating contours are.

Are there any rules you should follow to get the most out of the contours but not make stuff up or loose too much information?

Say I want to generate three sets of contours:

  • 250mm
  • 1m
  • 5m

Is there anything I should do to the DEM before each set?

Is post smoothing of the lines a good way to go or is smoothing the raster a better option?

4
  • 1
    What will you use the contours for? What are the positional and value accuracy statistics of the DEM?
    – whuber
    Sep 27, 2011 at 23:05
  • DEMs were generated from LiDAR so I would say they are pretty good. Well I would like a set for public viewing for the 1m and 5m and the 250mm with be in house for design proposals.
    – Nathan W
    Sep 27, 2011 at 23:17
  • 1
    For design proposals and in-house work you're likely better off using the DEM itself: compared to a set of contour polylines, it lends itself better to almost any calculation. Indeed, for public viewing you can often do well by overlaying key features (streams, ridges, peaks, etc.) on a hillshaded DEM. Do you really need to generate contours at all?
    – whuber
    Sep 28, 2011 at 14:58
  • I personally agree with @whuber, but I've gotten pushback on using a DEM due to cultural differences between different end users. Engineers (at least in my market sector) are reticent to use anything but contours. Additionally, contours can be overlaid on aerial imagery more easily than a DEM.
    – DPierce
    Nov 8, 2013 at 20:48

3 Answers 3

17

Cartographic rules to represent the relief as contours are presented in Imhof's famous book on relief representation, chapter C. Some of these rules are given on this wikipedia page. The main recommendation when simplifying contours it to preserve the terrain main characteristics.

Smoothing the contours independently do not prevent them to overlap: It is advised to smooth the DTM first. A traditional Gaussian smoothing with a suitable parameter depending on the target resolution allows to erase the small details. A drawback is that DTM smoothing fills the valleys and depressions, and flattens the ridges and peaks. Using the douglass-peucker filter algorithm like in this paper may be a solution. There are also number of methods based on the use of contour smoothing algorithms constrained by the drainage network or a skeleton. Finally, to prevent the contours to overlap in sloppy parts, it is possible to erase them locally or also deform them.

1

I want to second @whuber's comment. Quantitative Analysis is always better from a DEM directly and Visual Analysis is often better when done from a Hillshade rather than contours.

To answer the question directly: In ArcGIS I would use either Focal Statistics or Aggregate [Spatial Analyst Toolbox] to smooth the resulting contour lines. Because contours are a visual analysis feature the amount of smoothing will vary on your need. So you'll have to experiment and see what works best for your project.

Smoothing the lines after generating them does work but is a little clunky compared to modifying the raster first. One post-contour generation clean up I often do is to select the lines of a certain length (e.g. <10' long) and delete them. This rids the data of "noisy" little bits of closed contours (i.e. tiny loops) that are unlikely to reflect the actual character of the surface being modeled by the contours.

Other things you might look at [ArcGIS users] are:

Making a Raster Mosaic and/or Focal Statistics Raster Mosaic and use a model to generate contours for the whole dataset.

Making 3D contours for AutoCAD use.

Watch out for areas of unusual DEM data (e.g. large expanses of low lying ground needing different contour intervals to accurately represent the surface, areas of dense vegetation giving bogus Bare Earth values, areas of vertical relief - cliffs, etc).

1

There is a easy way using gdal_contour. After setting all option in the dialog window you can then edit the command line and instead the "-i interval" you can use fixed levels "-fl levels". Like the image shows bellow. You can check other options here http://www.gdal.org/gdal_contour.html

enter image description here

2
  • how does -fl help with smoothing? Sep 5, 2020 at 2:51
  • It does not. Smoothing needs to be done after or smooth the DEM before generating the contours. Oct 24, 2022 at 16:01

Your Answer

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

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