4

My version of QGIS is 2.8.

I want to convert a RGB raster into a polygon. I just need the boundary of it (not the rectangle extent but the boundary of the real feature). I have tried raster calculator but it says SAGA does not support multiband raster.

I also have tried the Vectorize raster layer tool but it takes a very long time because the resolution is very high. It gives me around 3000000 polygon for an image like below and I have a few hundreds this size of images.

Is there any other way to do it? enter image description here

  • Is it possible to add screenshot of raster ? – Shiko Dec 12 '16 at 2:38
  • yes, I just did it. – chenghopan Dec 12 '16 at 2:45
  • Have you looked at the Image Boundary plugin in QGIS? – Aaron Dec 12 '16 at 5:29
  • I did but for some reasons it gives me a rectangular extent – chenghopan Dec 12 '16 at 5:31
  • Try using the "valid pixels" option. – Aaron Dec 12 '16 at 13:17
2

I just figured it out... Use Raster Calculator:

band@1 * 0 + band@2 * 0 + band@3 * 0

Then will get a raster of two values, then vectorizing this raster will only take a second.

1

Try these steps, it might not be the best but it serves the purpose. It is based also on vectorization of Raster but with additional step:

1) Resample the Raster image to a lowest resolution. follow below link for example http://dominoc925.blogspot.sg/2015/04/resampling-single-geotiff-image-in-qgis.html
2) Use Raster to vector feature in QGIS.
https://docs.qgis.org/2.6/en/docs/training_manual/complete_analysis/raster_to_vector.html
3) Use the Dissolve feature to merge all polygons and form one final polygon.

You mentioned you have hundreds of files, why not using the Model builder to automate the process:
http://www.qgistutorials.com/en/docs/processing_graphical_modeler.html

  • But if I do that I will lose details on the edge? btw thanks for mentioning the Model Builder but I am planning to do it in the python console – chenghopan Dec 12 '16 at 3:52
  • I have been thinking to convert the image into a single band image, then use raster calculator to calculate all the pixel with value to 1, then turn that into 1 polygon. However, I can't find any way to convert the image in QGIS – chenghopan Dec 12 '16 at 3:54
  • 1
    It is not converting, it is extracting a band from multiband raster. Check this link gis.stackexchange.com/questions/62133/… – Shiko Dec 12 '16 at 4:04

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.