[GIS] Most optimal algorithm for contour correctness

ccontourgdal

Am creating an app which correctly calculates contours from a DEM file or any height-map given to it. The correctness of the contour holding the most importance, since a person viewing the contours shouldn't end up taking wrong planning decisions and maybe losing their life by the route they choose after looking at the map.

I have already tried using GDAL 1.7 source code, compiled it and added some features of my own to it for some other objective. Now I want to add-to/modify the source to be able to use the contour generation function of GDAL in C++.

But before proceeding, I wanted to know:
1. If GDAL offers the best free contour generation algorithm available or is there any other library which I can link to my code and feed my DEM map to it and receive contour vector lines (or go thru research papers and implement the contour generation algorithm myself in C++)? If GDAL, then why is it the best?
2. A generated contour will basically be points connected with straight lines. Is it more correct for a contour to be depicted with connected straight lines or will it give a more correct result to use a spline to smoothen out the lines?

I won't be interpolating any contours or the DEM because I've read on this website that interpolation leads to incorrect results.

Best Answer

I asked this question on the osgeo forum too, and some very helpful people replied. Would just like to list out the gist of the answers so that it'd be helpful to anyone who'd search for a contour algorithm later.

DEM or DTM files contain geographic features. Contours aren't geographic features; they're cartographic artifacts. The quality of the geographic features are important.The contour accuracy can never be more accurate than the source data. GDAL isn't the worst or the best. It gives an algorithmic result. Worst or best lies in your data, the processing chain of the data (interpolation/smoothing of DEM etc.) and your intended use.

The only case where route finding where wrong elevation can be life critical would be beach travel beneath sea cliffs and aircraft terrain avoidance.

As for interpolation, there's also the method of using TINS (intersecting the triangular 'faces'). Interpolation doesn't necessarily lead to incorrect results. DEM data is mostly already interpolated.

http://osgeo-org.1560.n6.nabble.com/Most-optimal-algorithm-for-contour-correctness-td5034148.html

Related Question