With the following expression presented in the question (Creating the minimum convex hull that contains certain percentage of points in QGIS) it is possible to calculate the closest distances between groups of points:
array_sum (
array_foreach (
overlay_nearest(
@layer,
$geometry,
limit:=2
),
length (
make_line (
$geometry,
@element
)
)
)
)
In the following screenshot I show the manual selection of the 20 points with the shortest distances from a total of 241 points (field "LONU"):
I would like to reuse this expression to build a Geometry Generator expression that:
1 → Selects the 20 shortest distances
2 → Finds a 4 groups of 3 closest points from this selection
3 → Draws the minimal_circle of each group
My goal is to reuse the above function to build an expression with the Geometry Generator that generates a geometry object like a minimal_circle from a 4 series of groups based on the distances and proximity between points. I show a screenshot with a simulation of the desired target:
My first approach (doesn't work):
with_variable(
'min',
array_sort (array_agg (LONU),0)[20],
with_variable(
'value',
4,
make_line(
$geometry,
eval (
'overlay_nearest (
@layer,
$geometry,
filter:= LONU =' ||@min||' and || @value || ')[0]
)
)
)
This expression doesn't work but I think it can give an idea of what I'm working on. Note that, at the moment, I try to draw a line but I would like to draw a minimal_circle or a convex_hull.

