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

Even Rouault even.rouault at mines-paris.org
Sat Mar 27 18:07:24 EDT 2010


Kishore,

Here is a process you could try:

1) Prepare an output GDAL file for gdal_rasterize.

You can take care inspiration of
http://trac.osgeo.org/gdal/wiki/FAQRaster#HowcanIcreateablankrasterbasedonavectorfilesextentsforusewithgdal_rasterizeGDAL1.8.0

Modify it to create 1 band (instead of 4) and for step 3) to work, you should 
take care of setting a nodata value on the output file and initialize the 
raster with it:

dst_ds.GetRasterBand(1).SetRasterNoDataValue(0)
dst_ds.GetRasterBand(1).Fill(0)

(if you can compile GDAL from source, you can avoid this step by grabbing the 
latest sources that have an enhanced version of gdal_rasterize, directly able 
to create the output file . See http://trac.osgeo.org/gdal/ticket/3505)

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.

Best regards,

Even

Le Saturday 27 March 2010 19:09:06 Kishore Reddy, vous avez écrit :
> Hi everyone,
>
> I am planing to use gdaldem to create relief shaded maps. But the
> problem is gdaldem takes only DEM files as input. Unfortunately I have
> contour lines (in the form of Shape files). So is there any way
> (command line) to convert these shape files into DEM files?
>
> --
> Kishore
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list