7

I am using QGIS 2.18.2 on a Macbook Pro running OS X 10.10.5.

I created a layer of only 8 points from a wildlife survey. A few points have become less relevant, so I want to hide them from the display. But I would rather not delete them from the shapefile.

Is there a way to do this? Or do I have to create a new, separate layer of the relevant points?

6

I would do this by:

  • adding a column to the attribute table, name that "visible"
  • check those points that you don't want to be visible as "no".
  • in the shapefile properties (doubleclick on the shapefile) select properties>style>categorized>
  • select the "visible" column, and click on 'classify'
  • EITHER delete the "no" records from the style dialog window
  • OR uncheck their visibility checkbox
  • OR make them completely transparent
5

If it is ok to add a field to determine show / no show of your points, for instance:

enter image description here

"Rule-based" styling can be set as "Show" = 'show' and "Show" = 'no show'.

On Rule properties window (by double-clicking on the 'no show' rule), you can tick-off the small box next to Symbol. This turns off symbol appearance.

When you need the hidden points back, turn the box on.

3

Another method is to set the Provider feature filter which can be accessed by right-clicking your layer and going to Properties > General > Provider feature filter. This allows you to filter your features based on their attributes. We can use this to hide certain features. What I used to do was (based on this post):


  1. Create a new field in your layer and use the expression:

    $id
    

    This returns the feature id. Then save the edits.


  1. Run the following code into the Python Console, this will programmatically set the filter. So you basically select the points you want hidden and the code will create the filter based on those selected points:

    def hide(field):
        layer = iface.activeLayer()
        expr = str(field) + " NOT IN ("
        for feat in layer.selectedFeatures():
            expr = expr + "'" + str(feat.id()) + "',"   
        expr = expr[:-1] + ")"  
        layer.setSubsetString(expr)
    

  1. Select the points you want hidden and (assuming the field name which contains the feature id is called "ID") then type the following in the python console:

    hide('ID')
    

    Notice the single quotes. Your selected points should now be hidden.

3

As long as there are only a few points to be hidden you could easily filter them even by listing their IDs (if necessary, when the respective points don't share a common attribute):

  • right-click the layer in layer-window

  • select 'Filter...'

  • type " 'ID' NOT IN ('id1','id2',...) " with 'id' being the point-IDs to hide and 'ID' the (name of the) unique ID-field

You can apply the same rule to any field-name / value combination to identify your points to hide, in case of an (unlikely) missing ID field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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