I have a raster layer in GeoTIFF format, with continuous data values between -1 and +1. For the colour map, I would like...

  • 0 to be green

  • = 0 to be grey
  • <0 to -0.25 to be pink
  • <-0.25 to -0.50 to be dark pink

...etc to 1. Is this possible with QGIS? I tried putting ranges in the colour map box, but it didn't work.

  • 2
    > but it didn't work. is not helpful. What did not work exactly?
    – user2856
    Commented Aug 14, 2012 at 1:29
  • Putting ranges in the colourmap Value box, e.g. using relational operators like in the example above. It reverts to 0 when the dialogue box is closed and reopened.
    – gisol
    Commented Aug 14, 2012 at 8:04

2 Answers 2


This seems to work for me on a -1.0 - 1.0 NDVI raster

  • Double click on the raster layer in QGIS table of contents/layer list
  • Click "Style" tab (1st tab on the left)
  • Select "Render as" -> "single band gray" and "Single band properties" -> "Color map" -> "Colormap"
  • Click "Colormap" tab (2nd tab from the left)
  • Click "Add entry" and add the following entries:
    • -0.4999999 (< -0.5)
    • -0.2499999 (>-0.5 <-0.25)
    • -0.0000001 (> -0.25 <0.0)
    • 0.000000 (=0)
    • 1 ( >0 <=1)

One way would be to classify your raster using GRASS r.reclass from the Sextante toolbox. You'll need a 'rules' text file to do this, there are some examples here. Example 2 is probably something like you'd need (with a bit of editing, of course). r.reclass groups raster values into classes following the rules set in the 'rules' text file.

  • I could reclass in QGIS too, using the Raster Calculator. I was hoping to do it from the Styles/Colormap dialogue, though perhaps it will be easier to reclass into a new raster.
    – gisol
    Commented Aug 13, 2012 at 14:33
  • If you use r.reclass you could then (if you wish) unleash the raster polygonzer on the raster to make a vector polygon shapefile for colour styling. Just a thought. N.
    – nhopton
    Commented Aug 13, 2012 at 14:43

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.