Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I calculated a raster as difference of two other rasters. Now I want to create a colormap where one colour represents negative values and one colour positive ones. The two colours should become lighter as they approach zero and around zero the colour should be white.

Here the colour scale I would like to use:

enter image description here

My problem in using the plugin "1 Band Raster Colour Table" is that it creates palettes where the colours diverge around some value above zero. In my case my values go from -6880 to 5539 with a mean of 104.

share|improve this question
add comment

2 Answers

Ignore the plugin and just create a color map manually in layer properties - colormap tab with 0 as white and brown and green at the ends with linear interpolation.

share|improve this answer
    
I think we now move in the right direction. But then I have only three entries... The map is not that good in explaining all the middle values, it is actually mostly white. Is there any why to automatically set more entries? The "classify" button does a good job, but then I have to manually reset all the colours... –  Francesco Feb 7 '13 at 11:03
    
Did you activate linear interpolation? To add more entries, simply click the "add entry" button an chose a value. –  underdark Feb 7 '13 at 11:10
    
Yes, it was activated. I noticed that I could actually reach my goal manually, by adding more entries and setting the colour. I just wonder if there is a way to avoid doing it manually. –  Francesco Feb 7 '13 at 11:14
add comment

I think the first thing to do is make an RGB colour ramp. You can get the RGB values for the colours in the ramp by loading the colour scale image (the one you posted above) into QGIS and then starting the raster Value Tool plug-in. As you move the pointer over the image you will see the RGB value for the point under the hand-tool being reported in the Value Tool window.

Next, you will need to make a table something like the one below. The first column contains raster values and the other three are RGB triplets. Save the file as a plain text file called (say) "ramp.text". The columns may delimited with spaces or tabs, in the example below I've used tabs. In the example table I've left it to you to replace the "x"s with sensible intermediate values.

5539    0   0   0
x   2   67  0
x   4   120 11
x   103 177 64
0   255 255 255
-x  201 111 61
-x  118 2   2
-x  79  0   0
-6880   0   0   0

Apply the colour table to the difference raster by going Raster -> Analysis -> DEM (Terain models). Set "Mode" to "Color relief" set "Color configuration file" to point to "ramp.txt" and give your output GeoTIFF a name. Then hit "OK" and see what you get.

There are other ways of colour rendering one-band rasters in QGIS, but this is the one I prefer. This way of working uses gdaldem color-relief, for more details see:http://www.gdal.org/gdaldem.html#gdaldem_color_relief

N.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.