46

Not sure if this option ever existed, but the new QGIS version hides a lot of things somewhere else and this seems so simple that I'm kind of convinced it was possible to do this before.

I have quite a large data set with ship tracks. I now want to analyse individual ship tracks (made from point layer with Points2One Plugin). However, it is so crowded that it is hard to look at individual tracks. I don't want to save each single track as a new layer, so I wonder if it is possible to select one track in the Attribute table and display only that one on the map/hide the others?

1
  • IN QGIS 3.18 the Properties of the Layer are organised differently and there is now no General tab. Is there still a Layer Subset option that can be used to filter the display and if so where is it to be found? Commented May 11, 2021 at 8:45

3 Answers 3

46

Kadeem's answer will prevent your features from being visible, but they will still be present, if you are trying to identify an individual ship track you may click an invisible feature by mistake. What it seems like you need to do is define your layer so that it's as if those features don't exist. In ArcGIS this would usually be done using a Definition Query, in QGIS the equivalent command is the Layer Subset. Go to the Properties of your layer, in the Source tab click on the button Query Builder (QGIS versions prior to 3.10 this used to be in the General tab, at the bottom in the Feature Subset box), to bring up the following window:

enter image description here

The Query Builder will help you create an SQL query to define what features in your layer should actually be displayed in your project. Note that the value needs to be stated between single quotes. Any features not returned by the query are made invisible, not just visually but entirely (they are not deleted from your data, of course, they're just defined out of existence until you remove the Layer Subset query).

8
  • Dan, thanks a lot!!! This is what I was looking for, a bit more complicated than I hoped but does the trick! Very helpful, thanks!
    – Kristina
    Commented Aug 27, 2014 at 16:26
  • That's idd the answer. Nice tip Dan!
    – kadéem
    Commented Aug 28, 2014 at 14:05
  • Weird. Some time ago I did this and it worked. Now I want to do it again on another layer and the Feature Subset box is grayed out, as well as the button of the QueryBuilder! Any suggestion??? Commented May 12, 2015 at 6:51
  • 1
    @SimoA. If your data is in Excel, you could filter it there, add a new field where you convert VALUE to 'VALUE',, then copy and paste that field into the query box using an IN query.
    – Dan C
    Commented Oct 11, 2016 at 19:47
  • 5
    In QGIS 3.10 you'll find the Query Builder in Layer Properties > Source > section Provider Feature Filter at the bottom right corner. When your subselection is applied, a filter icon appears behind the layer item in the Layers panel
    – kadéem
    Commented Jan 7, 2020 at 8:32
31

This is now possible using just selections and a rule-based symbology.

This requires the Expression Plus plugin (for QGIS 2.x. 3.0 has the functionality built in).

Create a rule based symbology with the filter of:

QGIS 3.0+ (from thequerist in the comments):

is_selected()

QGIS 2.12-2.18:

isselected( @layer_name )

Or QGIS 2.8:

isselected( 'ACTUAL_NAME_OF_LAYER' )

Now only the selected features that meet this rule will be shown.

You can also have an ELSE rule for all unselected features.

enter image description here

5
  • 1
    This is exactly what I was looking for - thanks for this answer
    – geobar
    Commented Oct 13, 2016 at 14:01
  • HeikkiVesanto, where i insert this filter?
    – newGIS
    Commented Aug 23, 2017 at 20:06
  • I have added a picture.
    – HeikkiVesanto
    Commented Aug 24, 2017 at 8:32
  • 1
    Using QGIS 2.18.14 and the expression that worked is isselected('layer_name'). Using (@layer_name) returned 0 results.
    – Techie_Gus
    Commented Dec 18, 2017 at 16:47
  • 3
    In QGIS 3 and above this feature is built in. You can find it under Record and Attributes in the Expression String Builder. Also, you do not need to put the layer name in anymore and do not forget to underscore between is and selected. Here is an example for QGIS 3 and above: is_selected().
    – thequerist
    Commented Oct 2, 2018 at 19:54
14

Kristina, I assume there is an attribute in your table which allows you to identify a single track? For example:

  point_id  |  track_id
------------+------------
     1      |     15
     2      |     15
     5      |     24
     6      |     24
     7      |     24

If you open the attribute table, you can find an epsilon symbol (in the figure below, the 4th one).

enter image description here

This allows you to type an expression; for example:

"track_id" = 24

When you confirm, all rows that satisfy your expression (that is: all points that belong to the track with track_id X) are selected. If you then click on the magnifier button, QGIS zooms to your selection in the map canvas. The selected features (points in your case) are highlighted.


What you can do is to apply a rule-based style. As such you can show an individual ship track using a given symbol or marker, and 'not show' all other points by giving them an 'unvisible' marker. The screenshot (part from Layer Properties) below explains how it works:

  • Rule 1: apply the given marker to all points having a value of 24 for track_id
  • Rule 2: apply the given marker (a circle with white fill and white border...) to all points that do not satisfy a track_id value of 24

enter image description here

In fact all points are still there (making them white will not make the rendering taking less time) but at least your eyes can relax!

3
  • Thanks a lot for your answer Kadeem! I am aware of the selection function and this works well, however, I literally have 500,000 points in a small area and just highlighting the tracks I am looking for is not enough, the map is still too crowded and confusing. Do you know if there is a possibility to block all not selected points or something like it?
    – Kristina
    Commented Aug 27, 2014 at 14:05
  • 3
    I edited my answer with another option below the line. I guess this will help you.
    – kadéem
    Commented Aug 27, 2014 at 15:53
  • Kadeem, this is so simple but effective - great idea, thanks so much!
    – Kristina
    Commented Aug 27, 2014 at 15:58

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.