4

I would like to make visible only these polygons, which are selected right now.

I tried to go with this hint:

Displaying only selected features on map in QGIS

but when in my expression I applied:

   is_selected('Preferred cell radius')

I got an error:

Cannot convert to feature

enter image description here

I tried to solve it by looking at this issue:

QGIS expression "get_feature" will not evaluate feature, when called within "is_selected"

by adding up three columns from my data attribute table:

   is_selected("Preferred cell radius", get_feature("Name", "descriptio", "new_name"))

but in this case, I have another error:

Eval error: Column 'Preferred cell radius' not found

There is also another option in the Atlas features

QGIS Atlas: Only Show Selected Feature

but it looks like I have to add the certain feature ID

How can I make only these items visible, which are already selected?

From the answer below I have situation soch as this:

I have selected an object by the attribute table. Now instead of the style defined with is_selected() I have the selection color set in the project. How to apply the individual style for this selection?

enter image description here

2
  • Does your layer have a column named "Preferred cell radius"? Commented Apr 6, 2022 at 15:31
  • 2
    Having the selection highlight is unavoidable when using is_selected(). If you selected your features using an expression, use that expression as a filter in the rule and the features will keep whatever symbology you apply to the rule (rather than using the expression to make a selection).
    – Matt
    Commented Apr 6, 2022 at 15:56

1 Answer 1

5

is_selected() expects a feature as input: is_selected(<the_feature>). If left empty, it uses the current feature, you could also write as is_selected($currentfeature). You can also reference a layer: is_selected(<the_layer>,<the_feature>)

You give a string 'Preferred cell radius' or a field "Preferred cell radius" to it, thats where these errors come from. Either use it as:

is_selected()

or

is_selected(layer,get_feature(layer,attribute,value))

In your case the first option combined with a rule based symbology should do it. If the features are related to another layer you do the selection in, the second one should be what you are looking for.

enter image description here

4
  • Hmm, the formula works, but the result is not necessary. How about not selecting features at the same time?
    – Geographos
    Commented Apr 6, 2022 at 15:39
  • See my question updated
    – Geographos
    Commented Apr 6, 2022 at 15:53
  • You cannot avoid that. Selected is selected. You cannot select and not select a feature at the same time. What you can do is changing the color/style for a selection in Settings -> Options -> Canvas & Legend -> Selection color. Maybe this makes your symbology obsolete at the same time.
    – MrXsquared
    Commented Apr 6, 2022 at 16:04
  • I would like to have the selection color synchronized with my symbology. Is it possible?
    – Geographos
    Commented Apr 6, 2022 at 16:30

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.