I would like to extract a polygon based on it's colour from a scanned map georeferenced in QGIS.

In the image, I would like to extract all of the blue as a separate shapefile/GeoPackage instead of having to manually trace it with the drawing tool. Is there a way to extract based on it's colour?

I've tried with the SCP plugin but have had no luck. Raster-polygon doesn't work for this either.

example of the image

2 Answers 2


You can get pretty close with:

  1. "Raster calculator". The turquoise areas have a red band value of about 100-120 (in my downloaded copy of your raster) the other colors a lot less or more, I used the i-tool to see this. So give them the value 1, and the rest 0 with:

    (("your_rasterlayername@1">100) AND ("your_rasterlayername@1"<120))*1 + (("your_rasterlayername@1"<100) AND ("your_rasterlayername@1">120))*0
  2. "Sieve" away pixel noise

  3. Use "Warp (reproject)" to set nodata to 0

  4. Vectorize

  5. "Buffer" with a positive value, then the same negative value to remove holes. Both with dissolve option enabled.

  6. "Multipart to singleparts"

enter image description here

  • 1
    Very helpful, I think this is a good solution for those unfamiliar with SCP. Nov 28, 2021 at 8:16

This is a method called classification. In QGIS, you can use the Semi-automatic-classification plugin (SCP) which is the best option as far as I know. You should open up the plugins panel, the SCP can be found while typing "semi" in the search bar. Click install plugin and now you should be able to see the SCP Dock at the right or left side of your user surface.

You have to define the band(s) of your raster. Then choose either supervised or unsupervised. The former helps you to extract different features by defining (region of interest) ROIs to teach the machine what to look for and how to label features; the latter helps you to extract features by defining values. For instance, if the rivers on your raster are blue, define RGB 0÷255: 59, 179, 208 (which is the RGB code for River Blue ) as rivers.

A thorough explanation and tutorial could be found here. Good luck.

  • 1
    Thanks Ash, I tried this but I couldn't get it working. I'll try again though as it does seem the best solution. Cheers Nov 27, 2021 at 15:11
  • Your welcome. Yes, Classification is a bit more complex than the common processing tools so it needs more time to be grasped.
    – Ash
    Nov 27, 2021 at 15:22

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.