6

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.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Tony Rowlands
  • 229
  • 2
  • 3
  • 7
  • Possible duplicate of http://gis.stackexchange.com/questions/111784/how-to-display-only-selected-features-on-map. The answer from Vesanto is rather cool, but requires a plugin. – AndreJ Nov 04 '16 at 17:00

3 Answers3

8
  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

alphabetasoup
  • 8,718
  • 4
  • 38
  • 78
7

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

Jonathan
  • 513
  • 5
  • 7
0
layer = QgsProject.instance().mapLayersByName('layername')[0]
layer.setSubsetString("'10'" + ' LIKE "fieldcolumn"')
Mariosmsk
  • 11
  • 2