2

Using QGIS, I want to calculate the percentage of a line feature (vector), covered by my viewshed analysis (raster layer), which is based on multiple observation points (purple points). I thought about reclassifying to: can be seen/can't be seen. Yet I have no idea how to calculate the amount of the line feature covered by the raster layer (visible). (The white areas cannot be seen by the observation points. Red, blue and green shows areas that can be seen by one or multiple observation points).

enter image description here

1 Answer 1

2

If your raster isnt huge this should work:

  1. Unless you already have an unique id on your line(s) add a field to your and calculate using field calculator. For example as row@number
  2. Field Calculate a line length field with $length
  3. Vectorize your viewshed
  4. Extract the polygons with values (my viewshed has 1 for visible, 0 for not visible, so I extract the ones
  5. Intersect lines and polygons
  6. Add line lengths to output
  7. Statistics per categories(id field) to get sum of line length per id
  8. Join back output to original line layer
  9. Add and calculate a percentage column ("sum"/"length")*100

enter image description here

2
  • Tried that, but as I suspected and you already pointed out too, the raster was too big.
    – Ben R
    Sep 6, 2021 at 10:17
  • Then I would try something with raster calculator. For example rasterize the line, overlay your line and viewshed and raster calculate 1 where they overlap and else 0, vectorize it back to a line, add a length field.
    – BERA
    Sep 6, 2021 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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