I have a SRTM elevation model with a point from which I would like to calculate the aproximate visibility. Using the line-of-sight tool in QGIs, I can achieve that without any difficulty. However, I'd like the tool to take in consideration the vector lines I have drawn around the point (the lines should serve as a blockage and visibility shouldn't pass through them).

Do I have to modify the raster DEM where this vector lines are (and set them to a height of 99999) or there is a way to make QGIS consider the vector lines while doing the viewshed analyses?

3 Answers 3


Editing DTMs in QGIS is very easy but not well documented. You can burn your polylines into the DTM using Raster->Convertion->Rasterize.

  • First add a level attribute to your lines - I'm assuming you could use something huge like 1 million here to block the view.
  • Once you've done that run the rasterize tool using your polylines as the input and your height field as the attribute field.
  • As your output raster select your original DTM raster (you might want to create a copy first).
  • Ensure you select 'keep existing raster size and resolution'

Hitting go should generate a raster with your line burned onto the surface.

The tool being implemented under the QGIS GUI is gdal_rasterize. The command line gives you more options which you can access by editing the code in the GUI window; '-add' is a good one as this will add the value you set for height to the existing cell values rather than burning it in from zero. The help file is here: http://www.gdal.org/gdal_rasterize.html.


Rather than editing the DEM, it might be easier to edit the resulting viewshed. For each blockage line, create a quadrilateral with one edge being the blockage line, two edges being lines that start at the endpoints of the blockage line and are radial to the view point, and extend far enough that the quadralateral contains all the points in the viewshed (or as far as you care about). Then clip out this region from the computed viewshed.

enter image description here

  • Even though I ended using the 'Serval' plugin to increase the z - values of the raster where I wanted the blockage to be, this seems like a really 'hacky' solution! Thanks for sharing it
    – escplat12
    Commented Dec 9, 2017 at 20:21

As far as I know, the hole viewshed process is only raster-based. I would propose to you to build a model for rasterizing and adding the values of the lines to your DEM with the raster calculator for a flexible solution to your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.