2

I have a layer with multiple points which have overlapping geometry. Each point is a control at a specific position with each individual attributes. They all have attribute "X" in common which can be either true or false.

I want a to create a overlapping order defining those points. If one point on the same position is true it should be "red dot". If all points are false "green". Can I create something like this by having multiple points on the same specific position?

3 Answers 3

4

You could define two rules in rule-based renderer:

  1. Green Dot X=false
  2. Red Dot X=true

then go to "Symbol Levels" and set the "Red Dot" symbol to '1', while the Green Dots are in Level '0' enter image description here

3

The simplest way is to use the "Control feature rendering order" setting from the layer styling panel. There you can input an expression that will determine in witch order your layer feature will be rendered (it will work only at the layer level(ie. for feature that are in the same layer), you cant override the layer order that way)

In your case you just need to input your "X" field as the expression and set the ordering (ascending or descending) according to the result you want (this work because you have only two attribute (True and False), if you get more than two value (for exemple True, False and Unknown) you may need to create an expression that reclass your value in the order you want)

enter image description here

3

You can use data driven override for the color and set an expression that evaluates the condition: if the condition is met, color is red, otherwise green.

If the points are exactly in the same place and you want to have the points in red if at least one of the overlapping points has value true for the attribute named x, use this expression:

if (
    array_contains( overlay_equals(@layer, x), true),
    'red',
    'green'
)

Several points on the same spot - if all points have value false, they are green, otherwise red: enter image description here


Variants

Adapt the expressions to your needs. If the points are nearby, but not exactly in the same place, use overlay_nearest, e.g. like this to color each "cluster" of points according to a condition if it contains at least one true value or not:

if (
    array_contains( 
         array_append(
            overlay_nearest(@layer, x, max_distance:=100, limit:=100), 
            x
        ),
        true
    ),
    'red',
    'green'
)

If the current point or any other points within 100 meters is true, color is red, otherwise green: enter image description here

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.