This QGIS layer tree widget adds an "Image Legend" entry into the Legend tab of a raster layer properties.
Distributed under the GPL licence
This widget works only on QGIS version ≥ 3.4.
Please report any bug/problem/wish on GitHub or, not recommended, to the QGIS User mailing list [mailto: qgis - user at lists dot osgeo dot org].
Contents
pillow could require manual installation and can be "pip install" from QGIS command line (pip install pillow
).
Minimum module version required to use this widget:
Follow instructions here to install this widget.
Then enable it in Plugin Manager. Its name is: Layer Tree Image Legend Widget
Once successfully installed the widget is found in Properties
-> Legend
-> Embedded widgets in legend
-> Available widgets
.
For raster layers only!
In order to work correctly this widget requires a specific sidecar file (specially named file) for the selected raster. Two cases are dealt with: 1) one legend sidecar file per raster or 2) a common legend file for all rasters in the directory that do not have their own legend sidecar file.
Case 1 - One legend sidecar file per raster file:
my_map.legend.png
or my_map.legend.jpg
where my_map is the name as the original raster file, without extension, and .legend.png
or .legend.jpg
is sidecar identity.Case 2 - Common legend for rasters in folder:
pref.legendcommon.png
or pref.legendcommon.jpg
where pref is a dummy name, and .legendcommon.png
or .legendcommon.jpg
must be as it is..legendcommon.png
or .legendcommon.jpg
can exist in the given directory. If more than one file exist then the one displayed is undefined.Let's say we want to georeference a map. That map is probably an image showing map content and a legend associated with it. Would it be nice to georeference the map content only and have the legend as a separate item displayed in the layer tree?
Well, this is now possible and to do it we need to prepare our map/legend pair.
my_map.jpg
) of the map with legend in an image editorpng
(or jpg
, from version 1.2) file named as follows: my_map.legend.png
where my_map is the same name as the original file, without extension, and .legend.png
(or .legend.jpg
) must be like that (this is a sidecar to the original image. This convention is necessary on order for the widget to find the legend from the raster name)Properties...
)Legend
tab to open itEmbedded widgets in legend
-> Available widgets
there should be an Image Legend
itemUsed widgets
paneOK
Map taken from pinterest
Download zip file here for manual installation.
Many thanks to Nyall Dawson at North Road for creating toggle_labels_widget on which this widget is based!
Published date: 25 Aug 2019.