I have a single band raster image with values of pixel 0 and 1. There's another line vector layer over the same area. I need to find the percentage of line which is overlapped by the pixels of value 1. I am thinking of using clipper in qgis or mask function in R but can't exactly figure out the way. Is there any way of doing this in QGIS or R?

  • You could convert the raster to polygons and take the intersection of the two layers. – csk Apr 19 '18 at 17:18
  • @csk.. I tried that but it shows an invalid geometry option while intersection. – Kuljeet Keshav Apr 19 '18 at 18:06
  • Solutions for invalid geometry of vectorized rasters: gis.stackexchange.com/questions/226955/… – csk Apr 19 '18 at 18:14
  • @csk Thanks for help! I used buffer to solve the invalid geometry. – Kuljeet Keshav Apr 19 '18 at 18:29

I used the polygonise option to convert the raster to vector. Then I used a subtle buffer as discussed here: Fixing geometry validity errors in QGIS?. Then, I used the intersect option to get the required layer.

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.