6

Starting from a layer with points geometry, the Geometry generator is used to create a line geometry layer that connects with the 8 nearest points. The function used is the following:

collect_geometries (
        array_foreach (
            overlay_nearest ('layer_of_points',
                $geometry,
                limit:=8,
                max_distance:=100
            ),
            make_line (
                $geometry,
                @element
    )
  )
)

The result obtained, as shown in the attached screenshot, is a set of lines. From this lines I would like to build a geometry expression that allows to detect and generates the 2 largest area polygons (features in blue color on screenshot) that arise from the triangulation of connected lines with points.

enter image description here

5
  • 1
    You question is not clear for me. There are lines under the blue areas, right? How do you define the border of blue polygons?
    – Zoltan
    Feb 10, 2023 at 7:04
  • Your observation is correct. I confirm that there are lines under the blue areas. Regarding the polygonal shapes, in the case of the screenshot I have simulated the expected result by drawing by hand these polygons
    – Acperience
    Feb 10, 2023 at 7:13
  • are you only interested in a solution with geometry generator ? If not it's quite easy with processing tools
    – Kalak
    Feb 10, 2023 at 7:19
  • You should find the rule for polygon borders, without this the task is not defined.
    – Zoltan
    Feb 10, 2023 at 7:21
  • The idea is to use the my expression that generates the connection lines with the tool Geometry by expression. With this way you get a lines geometry layer. Then, with this lines geometry layer you should use the Geometry generator to detect and polygonise the largest areas
    – Acperience
    Feb 10, 2023 at 9:04

1 Answer 1

3

I am not aware of any way to do this with the geometry generator directly. But I can propose the following process to achieve the intended result.

  1. use "Polygonize" processing tool on your line layer.

enter image description here enter image description here If step 1. failed you may need to run "Multipart to singleparts" first, then you need to run "Check Validity", and with the result you need to run "Split lines by lines"

  1. set a rule-based symbology with this expression as a filter:
array_contains(
     array_slice(
        aggregate(@layer, 'array_agg', $area, order_by:=-$area), 
        0, 
        1
    ),
    $area 
)

enter image description here

3
  • Great expression proposal. The result obtained is as expected. However, I would have liked to avoid the previous geoprocesses needed to validate the topological integrity
    – Acperience
    Feb 10, 2023 at 12:20
  • 1
    I understand the possible need for "Multipart to singleparts", "Check Validity" and "Split lines by lines". However, it is likely none of those are necessary in 99% of cases. "Multipart to singleparts" / "Split lines by lines" aren't necessary for "Polygonize" and the generated lines from your geometry generator can't be invalid unless maybe there are duplicate vertices. In which case the only geoprocess needed is "Remove duplicate vertices" in the initial point layer.
    – Kalak
    Feb 10, 2023 at 12:46
  • In the quick tests I am doing with 130 line geometries layer (converted into 900 single-part geometries), only the "Split lines by lines" geoprocess can be saved. It is acceptable because if it is understood that the topological tranformation (start with point layer and finish with polygon layer) geoprocess is not trivial to do all it with the Geometry generator. Good work!
    – Acperience
    Feb 10, 2023 at 13:20

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.