0

I am experiencing some issues eith the Geometry Generator (GG) in QGIS (I tested it both on 3.28.7 and 3.34.5 versions).

I had previously created a point layer with a double symbology, a point and a linestring created by the GG. The layer and the QGIS project share the same CRS projection.

The expression used to create the lines is this (similar to the one suggested here):

collect_geometries(
array_foreach (
    overlay_nearest( 
        'layer_name', 
        $geometry, 
        max_distance:=30000, 
        limit:=-1
    ),
    make_line (
        $geometry,
        @element
        )
    )
)

and it created lines connecting the points within a certain distance (in the provided example 30000 map units , i.e. 30 km). This worked well until some times ago when I reopened the project and realized this method is not working anymore. The issue I have encountered is twofold:

  1. if I write the expression in the GG of the point layer, nothing happens. But if I duplicate the layer, lines are drawn;
  2. the GG units are set on 'map units', so working with projected reference systems they should be meters, and this worked well in the past. Now it seems there is no correspondence between the GG units and the effective distance among points, so to make some lines appear I have to arbitrarily increase the max_distance, which makes no sense to use this expression;

I tried to create new projects and point layers as well but I could not find any solution.

1 Answer 1

3

It is known that the overlay_... functions behave strangely when applied on a single layer. See this bug report. There is even a special note for the limit:=-1 not being respected, so you can try to increase it to a high value, or, safer, to duplicate the layer.

Regarding the distances, it seems that the cartesian distance is used, not the elipsoid distance. Depending on the projection, it can make a huge difference.

1
  • I didn't consider the differences between Cartesian an ellipsoidal distances. I was using ellipsoidal so this is why measures were inconsistent. Is it possible to specify the method in the expression or is it mandatory to use only Cartesian calculations?
    – HyPhens
    Commented Apr 26 at 13:00

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.