# QGIS singleband pseudocolor color interpolation

In QGIS when defined a singleband pseudocolor symbology, the interpolation between 2 steps acts in a way I can't seem to understand.

Take for example step 1 and step 2:

• Value `0,0000002` is defined color `#000000`.
• Value `3,3752645` is defined color `#010204`.

On the raster a pixel with value `0.0759562` is rendered as color `#000000`.

The expectation would be that the value `0.0759562` would be interpolated between step 1 and step 2. The color to expect with linear interpolation would be `#0005CE`.

Is the interpolation between steps acting different the expected?

You have to consider the interpolation is done for each value of your hexadecimal rgb-triplet separately, in your example:

`r = #01, g = #02, b = #04`.

Calculate the ratio of `0.0759562 / 3.3752645 = 0.02252` approx. and multiply it with each of the rgb values separalety gives you

``````r: #01 * 0.02252 = #00 (rounded)
g: #02 * 0.02252 = #00 (rounded)
b: #04 * 0.02252 = #00 (rounded)
``````

or written as a hex triplet: `#000000` according to what you have observed.

The slight misunderstanding ist to consider the whole hexadecimal number `#010204` (`66052` in decimal) and calculate the portion of it with the ratio given above (`66052 * 0.02252 = 1487 approx. = #0005CF` according to your expectation).

This can easy be proven visually because #0005CF is some blueish tone that has clearly no place in between your two edge colors:

• Thank you for clarifying this. The new color having no place between the two edge colours is of no problem. What I am trying to achieve is to encode the values between min/max into RGB colours so to recalculate the value based on a hex triplet. Is this safe to do? Commented Aug 22, 2022 at 7:36
• The RGB triplet to pixel value idea leans on this shader idea: observablehq.com/@sw1227/decoding-png-elevation-tile. With the difference being the dynamic min/max value and thus dependency on the interpolation between bins I think. Commented Aug 22, 2022 at 7:41