Tuesday 19 February 2019

Using continuous color band for raster legend in QGIS composer legend?



I'm looking for a way to insert continuous colour legend for a raster layer. I managed to create discrete symbols with values along the bar, but I would like to have a continuous bar with some values on the bar, similar to the old plugin "One-Band Raster", that it doesn't work with the QGIS version higher than 1.7


I tried to set in properties->style, where I selected the Render Type "Singleband pseudocolor" and see the "generate new color ramp" box. I tried both "Continuous" or "Equal interval". However, in the Composer the legend always is displayed with discrete symbols.


Is there any way that can make QGIS Composer to display a nice continuous band for a raster layer?



Answer



A bit of a hack round to get composer to do this in QGIS 3


Add your legend, then adjust the symbol size in your legend to something small (example is 1.5mm). You'll still see white lines dividing the colour bands, these seem to relate to the font size for the legend text so set this to zero.


You can then add manual labels along the gradient and a rectangle to mask the legend text, or set that text to white.


This doesn't give a perfect gradient as some small white lines remain but for my purposes this was good enough.


Edit; This was tested on QGIS version 3.4.1-Madeira


As below;



enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...