1

I'm working with QGIS 3.28.5. I'm working on breeding bird data. I have a set of points where I heard a bird on a specific date. Now I want to separate the territories. My problem is, that I have to go to the query builder every time I finished working on the territories of one species.

Is there a way in QGIS to set the filter "just show all attributes with one species value and then the next one and the next one" As an example: I filter for "species" = 'Blackbird' and when finished I go back to the builder and filter for "species" = 'Robin'.

Does somebody have a suggestion or a recommendation for a plugin?

2
  • 2
    You could categorise your data and turn off all categories you're not interested in at the moment?
    – Erik
    Oct 10, 2023 at 12:48
  • 1
    Thank you. Didn't think of this easy solution. Oct 10, 2023 at 14:25

1 Answer 1

1

You can achieve something close to this using Python Actions.

Action 1 - Set Filter:

Create a Python Action to Set the filter such that only features matching an attribute of the current feature are shown. You can modify the following code to suit your needs:

from qgis.utils import *
layer = iface.activeLayer()
actionfilter = "species= '[%species%]'"
layer.setSubsetString(actionfilter)

This will set a filter on the layer to show all features with the same 'species' value.

Action 2 - Remove Filter:

Create a Python Action to remove any filters on the layer such that all features are shown:

from qgis.utils import *
layer = iface.activeLayer()
actionfilter = ""
layer.setSubsetString(actionfilter)

You can learn more about Actions here

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.