[gdal-dev] Converting contour lines (Shape files) into DEM

Frank Warmerdam warmerdam at pobox.com
Mon Mar 29 12:37:27 EDT 2010

Christopher Barker wrote:
> Even Rouault wrote:
>> 2) Use gdal_rasterize to burn the contour lines.
>> See http://gdal.org/gdal_rasterize.html
>> 3) Fill the holes (the nodata values) with gdal_fillnodata.py.
>> See http://gdal.org/gdal_fillnodata.html
>> Now, the result should be usable with gdaldem.
> well, yes, but it's likely to be pretty ugly -- it will represent the 
> elevation as steps -- constant values between contours. If you have 
> enough contour lines, and want a low-resolution DEM, that might be OK. 
> However, you'll get much prettier results if you interpolate in some way 
> to get a smoother result.
> Unfortunately, interpolating contour lines well is not trivial -- I'd do 
> some googling and see what you can find.
> GRASS may have something to help you here, too.


gdal_fillnodata attempts to do interpolation and was designed with the
idea of filling in between contours and holes in elevation products.   It
isn't perfect of course, but isn't the stepwise result you are expecting.

The algorithm effectively involves radial searches out from each pixel
to be interpolated, in 4 (or 8?) directions and then weighted distance
interpolation from the hits.  It also does some user defined number of
iterations of post-interpolation smoothing to minimize artifacts.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the gdal-dev mailing list