In QGIS 2.18.12 (qt4) on Linux, I repeatedly observe strange legend behaviour when new layers are loaded or generated using the Raster Calculator.
The legend will show colours for two classes (values). In the display window, the colours are apparently reversed.
At 1, we see that in the legend, nan is black and 0 is white.
At 2, I am clicking on the black field in the mgrid layer.
At 3, the value is 0. If I click outside the black field, the value is nan, which is the opposite of the expected behaviour.
If I reverse the gradient in Properties | Style | Band rendering, then the legend is "corrected" (nan is transparent, 0 is black) but in the display window, there are no discernable fields at all:
Updating the min/max statistics (with load min/max values) in the band rendering settings fills both fields with 0 and results in a legend that looks like this:
The image does not change (it is as it is in the first image above).
What causes this, and how do I fix it?