16

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 best, dietmar

underdark
  • 84,148
  • 21
  • 231
  • 413
dietmar
  • 161
  • 1
  • 1
  • 3

2 Answers2

14

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

takje
  • 103
  • 4
Cyrus
  • 1,498
  • 13
  • 18
5

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)

GabrieleMartini
  • 241
  • 2
  • 10
  • 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. – Francis Barton Apr 12 '21 at 18:38
  • @FrancisBarton, in my case I had to disable editing. – jiggzson Apr 13 '21 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. – Francis Barton Apr 13 '21 at 17:27