Monday, 1 October 2018

raster - Generating contours from DEM using GDAL?



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?



Answer



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.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...