I have a number of layers in the Layers Panel inside a group but I don't want them shown (there's quite a lot so it looks untidy). These layers are also joined to several others.
Is it possible to make these layers invisible to the user (i.e. not shown in the Layers Panel, it is not about setting the visibility of the layer) but can still be joined to other layers? Or perhaps make the group invisible?
Closest I found was this post but hoping there's a more direct approach:
Showing only some layers in QGIS legend?
Answer
I find making layers/groups 'invisible' useful to avoid showing lookup tables, which are required for value relations but might make the Layers Panel look a bit overloaded.
Just to clarify, invisible layers/groups will not appear in the Layers Panel, but they can still be seen in the canvas or used in joins/relations with other layers.
ANSWER:
Use the plugin Invisible layers and groups, which allows you to:
- Make selected layers/groups invisible (plugin button).
- Make layers/groups (that are invisible) visible again (plugin button).
- Store layers/groups visibility in your QGIS project.
- Recreate layers/groups visibility when opening your QGIS project.
- Make a particular layer invisible (by code).
- Make a particular group invisible (by code).
Making a layer invisible (by code):
if 'InvisibleLayersAndGroups' in qgis.utils.plugins:
ilg = qgis.utils.plugins['InvisibleLayersAndGroups']
ilg.hideLayer( layer ) # layer is a QgsMapLayer
Making a group invisible (by code):
if 'InvisibleLayersAndGroups' in qgis.utils.plugins:
ilg = qgis.utils.plugins['InvisibleLayersAndGroups']
ilg.hideGroup( group ) # group is a QgsLayerTreeGroup
ilg.hideGroup( 'group2' ) # You can also pass a group name
Note: There is an issue you should be aware of. If you make a layer invisible and then move its parent group, the invisible layer will be visible again (I don't know why!). So, my recommendation is to make only top layers/groups invisible (after all, you cannot move the root).
No comments:
Post a Comment