Generating DEMS from Contours in QGIS

Well, Today was a great day in my GIS works. A colleague asked “Can I generate a DEM of my region using QGIS?” This was my answer to them “YES”. Then they asked me “How?” I ended up spending the next one hour doing the demo on my laptop for them to grasp the rough idea on how to go about this issue.
That question motivated me to write this post so as to help other persons/groups out there who might be stuck in this issue like my good friend.
Here are the steps for generating a DEM (Digital Elevation Model) from CONTOURS using GRASS Plugin in QGIS.
To start, ensure you have the GRASS plugin installed in your QGIS (Plugins > Manage and Install plugins >GRASS)
Load the “Contours”  vector layer in QGIS.
Go to GRASS under the Plugins Menu


Select “New Mapset”.On the Grass Database window,select the folder in which your project will be stored and Click “Next”
On the Grass location, select “Create new location” and give it a name and click “Next”.


On the “Mapset” window give a name to the Mapset you are about to create and click Next




After this, the “Create Mapset window ” should display showing all the settings we’ve made.Click Finish.











A red Rectangle should be drawn on the QGIS canvas surrounding the extents in use.
Next
We need to add a Vector layer into the GRASS Mapset



Go to Grass > Open Grass Tools


The window below appears.In the “Module List” search for v.in.ogr.qgis (To import the loaded vector layer into GRASS) and click on it.
In the module “Options” tab select the “contours” layer,Name for the output map and also the name for the new location and click “RUN”.
The progress is shown in the “output” tab.Click on the “View Output ” button to view the layer in GQIS canvas.




Results of first module

Still on the “Grass Tools” Window, on the “”Module List” tab search for v.to.rast.attr (We need to convert the vector layer into Raster) and click to launch.
Second module
 Select the attribute field to be used (in this case “ELEV”)
Setting parameters

Results of second module

Now that we have the raster layer, we can now generate our DEM.



On the Module List, search the r.surf.contour (to generate DEM from the rasterized contour layer).Enter the name for the output and click ‘Run’ then ‘View output’ and Close.
Progress in Generating DEM


 The end results should be a DEM
DEM created

Raster Contours layer overlay on DEM
 We've just created a DEM for the region of interest.Try this and give comments.