17

I am trying to display certain features in a shapefile-based layer using QGIS. I have found the subset function in the properties panel, which does exactly what I want but is too tedious given that I have to manually sift through a large number of features. Is there a quicker way to do this?

I am using both shapefiles and PostGIS.

Taras
35.8k5 gold badges77 silver badges152 bronze badges
asked May 22, 2012 at 22:17

3 Answers 3

15

In QGIS you should be able to filter your data with an SQL expression in the Query Builder dialog. Just right click your layer in the table of contents and select "Query" ("Filter..." in the more recent versions).

answered May 22, 2012 at 23:19
1
  • 8
    In recent versions the dialog option "Query" has been renamed to "Filter..." Commented Nov 29, 2016 at 17:02
7

Tested on QGIS 3.10.2-A Coruna

How to apply a filter
* Right-click on the layer listed in panel Layers
* Choose Filter...
* The window Query Builder is displayed

How to build a query in Query Builder
* Double click on a field in Fields list
* Select All in Values
* Choose a operator from Operators
* Double click on a value in Values list
* Your expression is shown at the bottom of the window
* Click Test to have a preview of how many rows are returned
* Click OK to apply the filter
* The layer is displayed according to the filter applied (you see a filter icon aside the layer name in panel Layers)

answered Feb 27, 2020 at 13:21
4
  • 2
    I regularly use the Filter feature in QGIS. However in a new project I have just started, I have layers where there is no Filter option available, and the Layer > Filter menu option is greyed out. Does anyone know why a certain layer might not be filterable? I have not come across this before. Commented Apr 12, 2021 at 18:38
  • @FrancisBarton, in my case I had to disable editing. Commented Apr 13, 2021 at 15:20
  • In my case, the "toggle editing" menu item is greyed out, and the entire Edit menu is similarly greyed out and unavailable. Commented Apr 13, 2021 at 17:27
  • I noticed that you must not be in edit mode in order to use the Provider Feature Filter Commented Sep 5, 2024 at 13:49
0

Filtering for displaying

  1. Right-click on the vectorial layer
  2. Source tab
  3. Provider feature Filter
  4. Query builder
  5. Create your SQL for the features you want to keep.

Works on QGIS 3.40.3-Bratislava

answered Mar 24 at 19:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.