In this QGIS tips and tricks series I will show you how to filter or display only certain features in QGIS map view. For example, you have a road data with some types or classes like arterial, secondary, residential, etc. But you want only to view arterial road (red roads as seen in figure 1).
|Figure 1. Roads with several classes|
Open the layer's properties by double click of the layer or right click and select Properties... The layer properties window will appear as in figure 2. Select Source and below the Provider Feature Filter section select Query Builder.
|Figure 2. Layer Properties|
In the Query Builder window give an expression to filter a certain feature to display as seen in figure 3. The expression can be constructed by selecting a field's attribute which will be used as filter query. To see all the the attribute's value select All button on the right Values section.
|Figure 3. Query Builder|
The example above is a simple filter feature. In principle you can create many filtering scenarios using the expression. For example to display two classes of roads(Arterial and Secondary Arterial) the expression will be: "USE"='Arterial' OR "USE"='Secondary Arterial'
After constructing the query or expression in the Query Builder, the expression will be filled in the Provider Feature Filter as seen in figure 4. The filter result is shown in figure 5, that only display Arterial roads.
|Figure 4. Filter Expression|
|Figure 5. Map View with Filtered Roads|
That's all the tips and tricks how to filter certain feature which will be viewed in the map. For other interesting tips and tricks please visit QGIS Tips and Tricks Series. Thanks!