2

How do I center the color ramp on '0' for a series of raster with positive and negative values?

The values are non-normally distributed.

There doesn't seem to be a an 'absolute' option, only relative (circled, below).

enter image description here

Bonus: The min/max values change from one raster to the next, so it would be nice to be able to both: A) have the ramp autoscale around zero and B) color map the range of values absolutely (e.g. based on values from raster with the abosolute max and the (possibly different) raster with absolute min).

I'm running QGIS 3.10

There does not appear to be a "Symmetric Classification" option for rasters as indicated for polyline symbology in this post:

https://gis.stackexchange.com/a/385536/17482

2
  • 1
    You can calculate the percentage on the color ramp of your absolute value, see this solution here: gis.stackexchange.com/questions/386968/…
    – Babel
    Feb 14, 2021 at 22:03
  • Not what I was hoping for, but that will work. cheers for the reply!
    – CreekGeek
    Feb 14, 2021 at 22:17

1 Answer 1

1

The only way I was able to get the repeatability I was looking for was to make a custom colormap.

Created in a text editor:

# QGIS colormap for HARs
INTERPOLATION:DISCRETE
-9999,0,0,0,0,None
5.0, 15, 5, 239, 255, a
4.0, 0, 107, 255, 255, b
3.0, 59, 161, 246, 255, c
2.0, 94, 208, 246, 255, d
1.0, 147, 244, 244, 255, e
0, 255, 255, 255, 255, f
-1.0, 248, 186, 147, 255, g
-2.0, 244, 140, 97, 255, h
-3.0, 247, 99, 52, 255, i
-4.0, 248, 70, 32, 255, j
-5.0, 249, 11, 11, 255, k

where the sequence is

value, R, G, B, alpha, label

Then, add to raster symbology via:

enter image description here

also see this thread: Load and convert .txt file to .qml for raster color map

Then save as a style:

enter image description here

I also want to recognize this post: https://gis.stackexchange.com/a/50248/17482

Which provided initial inspiration for creating a text file and exploring the GDAL Color Relief approach which worked OK for one-off visualisation. [Note that Color Relief accepts a simpler form of the text file].

Ultimately, I found the approach I outlined above gets me to where I wanted to be for consistency across multiple layers faster, without loss of cell values, while providing a more straightforward approach to generate a legend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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