So I've been trying to convert a georeferenced Tif raster file into a vector shp file using QGIS. It's seems to complete this but it ends up giving me a feature class that has over 500,000 features, almost like it's creating a row per pixel. So with that many features it's very hard to work with and when I do finally get it to Classify like into 8 classes of natural breaks, it doesn't look like the original tif file. My end goal is to only have a few (less than 20) polygons based off the raster not thousands. Could it be that the Tif file I'm using is already pre-processed or something?

  • 2
    What does the raster represent? Is it continuous data or discrete? If it is the former, I would suggest creating isolines (contours) rather than just vectorise directly. If it is the latter, you will have to agregate your data in some way to reduce the polygon count. It sounds like you have continuous data or possibly are vectorising using an id field and not the attribute value. Jun 10 '12 at 7:19
  • It's vegetation growth so there are clear areas of strong and week growth. So I guess it's more discrete. I have both a near-infrared and NDVI version. What would you suggest the data be aggregated?
    – wilbev
    Jun 10 '12 at 16:50

It sounds as if your raster needs to be classified, which you can do using the experimental Sextante toolbox.

Each pixel in a one-band raster has a value attached to it and using GRASS v.reclass from the Sextante toolbox allows values to be grouped into classes. Say for example I have a raster with values of between 0 and 1400; using v.reclass I could group the values into seven classes, using this 'rules' text file:

0 thru 200 = 1
201 thru 400 = 2
401 thru 600 = 3
601 thru 800 = 4
801 thru 1000 = 5
1001 thru 1200 = 6
1201 thru 1400 = 7

The output would be a new raster having a value of 1 for all of the values of between 0 and 200 in the original raster, of 2 for all of the values between 201 and 400 in the original raster, and so on.

Once classified, the raster could then be polygonised.


  • Nick, Thanks for the answer. Where do I find the Sextante toolbox that I guessing can be added to QGIS?
    – wilbev
    Jun 10 '12 at 16:44
  • 1
    Hi, it's a plugin so you can add it by going Plugins -> Fetch Python Plugins... You might need to enable experimental plugins, under the 'Options' tab. In QGIS it will appear under a new menu item, 'Analysis'. Nick.
    – nhopton
    Jun 10 '12 at 17:27
  • I'm still struggling to get this v.reclass to work. First off, I don't think I have the rules text file right since I only get a black image as a result. So my Tif image has 3 bands and all 3 Red, Green, Blue go from 0 to 256 and they have different means as shown on the Metadata tab. Is that what you mean by having values? So will my rules be run on all 3 bands? I'm sure I'm not doing something right here.
    – wilbev
    Jun 27 '12 at 23:32
  • Ah, your raster is an RGB image. I'd wrongly assumed it was a one-band data raster, perhaps something like a DEM. I'm not sure where we go from here, is the data available as a one-band data raster?
    – nhopton
    Jun 28 '12 at 8:32
  • Actually the v.reclass will work on RGB - it just takes the first band. This approach worked well for me where it just happened that the polygon I wanted to extract was a single colour with a specific Red value. Not sure if you can specify the specific band in the full module - I only looked at the Sextante version.
    – Adrian
    Apr 16 '13 at 21:09

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.