1

I´ve create a project now with a rule based symbology and there are problems with my geometry generator. I ´ve got two point layers "buffer" and "GNSS". Both with identical styles. There is a geometry generator script that place a point on intersection of nearest boundary. (white point)

collect_geometries(
array_foreach (
    overlay_nearest (
        @layer,
        boundary(make_circle($geometry, "Radius" )),
        limit:=9 -- max number of towers to consider
    ),
    Intersection (
        boundary(make_circle($geometry, "Radius" )),
        @element
    )
))

Now on my "buffer" layer all works fine, but in "GNSS" it shows me many white points? The script is from this forum, I don´t know where.

link to sample QGIS Job


I delete this geometry generator now, because of problems with vertex tool. I can´t move the point with vertex tool. It´s locked. When I delete the white intersection point (geometry generator), all works fine.

overview settings

4
  • 1
    Could it be that the radius of both circles is the same in this case and the two circles overlap completely?
    – Babel
    Commented Oct 25 at 9:37
  • no, for this example there are two points (not on same position). When I change one radius to perhaps 15 and the other 10, it´s the same. In the other layer with same settings, it works fine. Commented Oct 25 at 10:24
  • new link on google Commented Oct 25 at 14:53
  • Look at the small circles Gnss. Activate Buffer to true as field value. Best in attribute form view. The white points should only on intersection of boundaries. Commented Oct 25 at 19:01

2 Answers 2

3

The overlay_nearest function is returning two points, itself and the other nearest one. See here: QGIS expression: when using overlay_nearest sometimes a feature considers itself its nearest neighbour

When the label from the post above is applied it shows the two fid's: 2 fids

Both the second point and itself are returned from overlay_nearest. The boundary around the circle then intersects itself on one of the iterations causing the white points to appear around the outside. For this specific case, the expression can be changed to get the second element from the array.

collect_geometries(
    Intersection (
        boundary(make_circle($geometry, "Radius" )),
        array_get(
            overlay_nearest (
                @layer,
                boundary(make_circle($geometry, "Radius" )),
                limit:=9 -- max number of towers to consider
            ), 1 --get the second one
        ) 
    )
)

After the change: expected intersection

4
  • Interesting approach, +1! ... but the problem is that "self" is sometimes returned, sometimes not, and this can suddenly change while playing with the layer!
    – JGH
    Commented Oct 25 at 19:44
  • wow, now the upper two circles are OK, but the two bigger one from "Buffer" Layer won´t work with this script. Commented Oct 26 at 6:28
  • When I add a new point with buffer to the PunktewithBuffer intersecting the two one, the script will work. But what also happens, that I can not move the two points. is it possible to unlock these? the third new one can be moved. Commented Oct 26 at 6:35
  • Instead of getting the second item in the resulting array (which may or may not include the current feature), maybe filter the array of features to exclude those with the current feature $id?
    – she_weeds
    Commented Oct 29 at 0:44
1

overlay_nearest behaves badly when applied on the same layer, as it sometimes consider a geometry to be near itself, sometimes not.

When it does not consider itself as being near itself, the result of intersection is a (multi)point, and can be displayed as such (your working case).

enter image description here

However when it considers itself, then the result of the intersection is a (multi)line, and only the line is considered when styling it. That is, the intersection point between two different towers is lost.

enter image description here

As you have witnessed, this behaviour is not constant, so your style could magically start/stop working!

There are two alternatives:

  1. work with polygons. Create the circle, then buffer them by a tiny bit and get the intersection. Style the output polygon as centroid fill. You might still get a dot at over the center point, so make sure to put this style below the style for the tower!
collect_geometries(
array_foreach (
    overlay_nearest (
        @layer,
        buffer(boundary(make_circle(@geometry, "Radius")),0.01),
        limit:=9 -- max number of towers to consider
    ),Intersection (
        buffer(boundary(make_circle(geometry(@feature), "Radius")),0.01),
        @element
    )
    ))

enter image description here

  1. Alternatively, you can work on filtering the result so "self" is ignore. See this post for some options.
1
  • Thank you JGH, but I don´t understand what you mean. I put the buffer and the 0.01 to my script, made a normal polygon fill with a centered point. Nor first it seams to be OK, but when I zoom in, the center point move from center, where the intersection points are ok. And in my styling the white point is now over the red center point. Your alternative filter link is too difficult for me. I don´t understand this. The generator script is one to one from here. Commented Oct 25 at 20:43

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.