5

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?

6

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)
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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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