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.
3 Answers 3
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).
-
8In recent versions the dialog option "Query" has been renamed to "Filter..."the_skua– the_skua2016年11月29日 17:02:24 +00:00Commented Nov 29, 2016 at 17:02
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
)
-
2I 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– Francis Barton2021年04月12日 18:38:56 +00:00Commented Apr 12, 2021 at 18:38
-
@FrancisBarton, in my case I had to disable editing.jiggzson– jiggzson2021年04月13日 15:20:01 +00:00Commented 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.Francis Barton– Francis Barton2021年04月13日 17:27:45 +00:00Commented Apr 13, 2021 at 17:27
-
I noticed that you must not be in edit mode in order to use the Provider Feature Filterjulsbreakdown– julsbreakdown2024年09月05日 13:49:26 +00:00Commented Sep 5, 2024 at 13:49
Filtering for displaying
- Right-click on the vectorial layer
- Source tab
- Provider feature Filter
- Query builder
- Create your SQL for the features you want to keep.
Works on QGIS 3.40.3-Bratislava