The main problem you are experiencing is related to the difference between the color palettes you are applying within QGIS and gdaldem color-relief
. The use of the -nearest_color_entry
flag makes the 'raster value' specification in colors.txt
not behave like a lower or upper bound, but more like a midpoint in that band of the color bar. You have a few options going forward:
(1) Adjust the 'raster values' in colors.txt
to be midpoints (less desirable).
(2) Add more rows to colors.txt
and set two values for each color, lower (inclusive) and upper (exclusive) bounds. It would look like:
0.0000000001 215 25 28 255
0.1799999999 215 25 28 255
0.18 253 174 97 255
0.3599999999 253 174 97 255
0.36 255 255 192 255
0.5299999999 255 255 192 255
0.53 166 217 106 255
0.7099999999 166 217 106 255
0.71 26 150 65 255
nv 0 0 0 0
You would still use the -nearest_color_entry
option in this case.
(3) Use a different type of color table, namely a GMT .cpt
as permitted for GDAL > 1.8.0. Such a CPT file would look like:
# COLOR_MODEL = RGB
0 000 000 000 0 000 000 000
0 215 025 028 0.18 215 025 028
0.18 253 174 097 0.36 253 174 097
0.36 255 255 192 0.53 255 255 192
0.53 166 217 106 0.71 166 217 106
0.71 026 150 065 0.89 026 150 065
The syntax of this CPT file is
low_bound RRR GGG BBB high_bound RRR GGG BBB
with an interpolation between the low_bound
and high_bound
. Setting the colors the same makes it a block of color. No need to use -nearest_color_entry
here. Your nodata value of 0 explains the first entry.