One of the layers has around 5000 attribute entries, based on a CSV file of species records. All the features are of course shown on the map layer. How can I select a specific class of features so that only they appear on a map, so that for example a distribution map for a species can be generated. I have tried "Advanced Filter (Expression)" so that the Attribute Table shows only the required species, but it still shows all the attributes on the map layer.

I am using QGIS 2.10.1.


3 Answers 3

  1. Double click on your layer in the table of contents to go to Layer Properties.
  2. Go to the general tab (hammer and screwdriver icon).
  3. Look for "Feature subset" and enter an expression (perhaps using the Query Builder button). For example: "species" = 'homo sapiens'. This would restrict the features to only those records meeting this criteria.

Example:enter image description here


The previous answer is not valid anymore for QGIS 3.4:

  1. Double click on your layer in the table of contents to go to Layer Properties. (like
    in QGIS 2)
  2. Go to Source Tab
  3. Click on Query Builder below the "provide feature filter" section

enter image description here

layer = QgsProject.instance().mapLayersByName('layername')[0]
layer.setSubsetString("'10'" + ' LIKE "fieldcolumn"')
  • 1
    You're using typographical (curly) quotes rather than straight ASCII quotes. I don't know of any programming language where that works. Commented Jul 22, 2019 at 10:40
  • I have updated my answer. My fault. Thanks for your tips.
    – Mariosmsk
    Commented Jul 22, 2019 at 11:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.