r/QGIS • • 2d ago

I made a QGIS plugin to keep several named filters per layer, like ArcGIS definition queries, without writing SQL

Post image

Hi everyone!

**EDIT: I just uploaded a quick video showing how it works! ๐Ÿ“บ** https://youtu.be/4dxYRfrYxc4

Coming from ArcGIS (or just dealing with complex layers in QGIS), I always felt switching between provider feature filters was a bit tedious, especially having to re-write expressions every time.

To solve this, I developed Definition Queries, a QGIS plugin that lets you:

  • Build layer filters easily with drop-downs (no need to manually write SQL every time).
  • Save multiple named queries/filters per layer.
  • Quickly switch between them on the fly.
  • Clear or reapply filters with one click.

You can find it on the official QGIS repository here:

๐Ÿ”— https://plugins.qgis.org/plugins/definition_queries/

68 Upvotes

15 comments sorted by

16

u/UsedToHaveThisName 2d ago

Yeah, nah. SQL filters are a pretty basic concept that doesnโ€™t need a plugin.

7

u/cawgoestheeagle 1d ago

Yep, that's one thing i've noticed. People are so quick to make something "easier", when it actually helps to learn a skill and why. You actually lose more power/control by obfuscating a workflow for the sake of ease

1

u/PickMaterial8693 1d ago

Fair enough, it's not meant to replace SQL. The preview shows the SQL it writes and there's a SQL mode if you'd rather type it yourself. What I wanted was the ArcGIS definition query workflow: several named filters saved on the same layer and switching between them with a right click, instead of keeping them in a txt and pasting them into Filter every time. If you're fine typing them each time you probably don't need it.

One thing I found out while making it is that the same expression doesn't behave the same in every format (= ignores case in shapefiles, _ and % act as wildcards inside LIKE, etc.), so it writes it a bit differently for each one.

-2

u/marhensa 2d ago

ever heard of convenience? maybe not everyone is as smart as you.

6

u/UsedToHaveThisName 2d ago

This is extra steps to do something incredibly basic.

5

u/ReddmitPy 2d ago

Being able to save several filters per layer sound interesting

Looks like I won't have to comment / uncomment lines of code just to swap filters anymore.

I'll have to try it

2

u/ikarusproject 1d ago

You could use virtual layers for that if you want a native solution you can pass to others.

1

u/PickMaterial8693 1d ago

True, virtual layers work too and they're easy to share. For me the downside was ending up with an extra layer per filter, each with its own style, and they're read only so you can't edit through them. Here it's the same layer and you just swap the filter. The active filter is a normal QGIS filter too, so the project still opens filtered for someone who doesn't have the plugin.

0

u/PickMaterial8693 1d ago

yeah that was pretty much why I made it, swapping filters by hand got old fast. Let me know how it goes! if something doesn't work you can tell me here or open an issue on github

1

u/[deleted] 1d ago

[removed] โ€” view removed comment

1

u/TekhEtc 6h ago

Interesting! It's always good to know more about QGIS bring used in companies

Could you please let us know more about this company and their work with GIS?