November 2018
Beginner to intermediate
272 pages
5h 36m
English
To filter vector layer features programmatically, we can specify a subset string. This is the same as defining a feature subset query in the Layer Properties | General section. For example, we can choose to display airports only if their names start with an A:
v_layer.setSubsetString("NAME LIKE 'A%'")
This will return true in the Python Console. Open the attribute table to see the results of the filter. This is demonstrated in the following screenshot:

To remove the filter, just set an empty subset string as follows:
v_layer.setSubsetString("")
Read now
Unlock full access