7

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

benchenggis
  • 1,406
  • 2
  • 12
  • 30

2 Answers2

4

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.

benchenggis
  • 1,406
  • 2
  • 12
  • 30
2

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

Shiko
  • 2,883
  • 13
  • 22
  • 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 – benchenggis Dec 12 '16 at 03: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 – benchenggis Dec 12 '16 at 03:54
  • 1
    It is not converting, it is extracting a band from multiband raster. Check this link http://gis.stackexchange.com/questions/62133/how-to-export-only-one-band-from-an-image-using-gdal – Shiko Dec 12 '16 at 04:04