1

Shapefile has visibility attribute. This attribute is generated by algorithm and there is a manual override.

In QGIS, is there a way to apply global (per project) or local (per layer) filtering to show relevant features for given scale?

For example, if current scale is

  • 1:25k render all features where visibility >= 5
  • 1:10k render all features where visibility >= 6
  • ...
1
  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Jul 23, 2016 at 11:01

2 Answers 2

3

You can use rule based rendering for this. Every rule has minimum and maximum scale attributes and will only be visible within these bounds.

For your case, make 2 rules:

  1. Filter: visibility >= 5, Min scale: 1:25000, Max scale: empty
  2. Filter: visibility >= 6, Min scale: 1:10000, Max scale: empty

This way you can even give the features different styles based on the scale or have the visibility defined by an arbitrary expression (road_type = 'highway')

There is a short mentioning of this in the docs:

https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#rule-based-rendering

If you want a complex example, have a look at these styles:

https://anitagraser.com/2014/05/31/a-guide-to-googlemaps-like-maps-with-osm-in-qgis/

3
  • I believe that rule-based rendering is not useful in this case: feature filtering is independent to style.
    – mys
    Jul 23, 2016 at 12:02
  • Then i have troubles understanding the question. Only features matching a rule will be rendered, anything else is filtered. Jul 24, 2016 at 15:45
  • Ideally, filter condition (on layer) should be scale aware. This is not an issue with few layers but having 10+ layers where each layer has several rules already makes this difficult (adding scales to existing rules). The second issue is to have multiple copies (of the same layer) and make styles consistent.
    – mys
    Jul 25, 2016 at 9:13
0

In general properties of the layer there is a Scale dependent visibility. I think you would need to set that manually for each layer.

If you want to render different features of the same layer at different scales then you can just add copies of the layer with different filters and scale visibility settings.

You can use pyqgis to automate this based on the rules you want.

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.