8

I'm working on a project that requires a lot of layers.

Because of this, even if i make different folders, it's sometimes hard to find the layers I want.

Is there a way to simply write a keyword somewhere to find (or highlight) the layer I want in the layers panel?

Is there a plugin for this?

For Example: I want to find the layer "Layer-Orange".

Where can I write "Orange" to find the specific layer?

0

4 Answers 4

9

With a bit of Python, you could search your layer by name, set it as the active layer and make it visible. You can enter the following in the Python Console (from the menubar: Plugins > Python Console or press Ctrl + Alt + P):

layer = QgsMapLayerRegistry.instance().mapLayersByName('Layer-Orange')[0]
iface.setActiveLayer(layer) 
iface.legendInterface().setLayerVisible(layer, True)

If you want to use keywords, you can loop through all layers in the list and find the layers which contains the keyword in the layer name:

for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    if 'Orange' in layer.name():
        iface.setActiveLayer(layer) 
        iface.legendInterface().setLayerVisible(layer, True)
1
2

The loop idea by @Joseph is good.

I just change the find_layerof your code to a simple layer

for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    if 'Orange' in layer.name():
        iface.setActiveLayer(layer) 
        iface.legendInterface().setLayerVisible(layer, True)
0
1

You can do this without python. I believe the original question was looking for a way to do this with the GUI. You just go to the search bar at the bottom left of the main map and enter 'L ' (case insensitive) and a few letters from the layer name. It will bring up a list of results as you type. Double click on the one you are looking for and it will select the layer and scroll to its position in the layer list.

0

For QGIS 3.>

for layer in QgsProject.instance().mapLayers().values():
    if 'Municipal_Boundaries_of_NJ' in layer.name():
        iface.setActiveLayer(layer) 
        iface.legendInterface().setLayerVisible(layer, True)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.