# How to label the number of points within a concave_hull avoiding duplicate counting

From a layer of points with the "CLASS" field reported with 3 different values, I apply the following expression to draw the concave polygon for each different value:

``````concave_hull(
collect(
\$geometry,
group_by:=overlay_nearest(@layer,"CLASS"))
,0.2)
``````

Next, I use an expression to label the percentage of points within each concave hull polygon:

``````round(
with_variable(
'num',
concave_hull(
collect(
\$geometry,
group_by:=overlay_nearest(@layer,"CLASS"))
,0.2),
aggregate(
@layer,
'count',
1,
within (\$geometry, @num) or intersects (\$geometry, @num)
)
)

/ count('')  * 100.0,0) || ' %'
``````

As can be seen, the total value is 103 % because it seems that there is a point that is count by duplicated in two different concave hull polygons:

How could I fix the label expression so that it takes this possibility and so that the percentage is balanced?

• If I understood you correctly, you create the polygons based on the `class` field. So why don't you use the same `class` field to calculate the percentage? Oct 23, 2023 at 7:09

As you want to number the points per hull and the hull is based on the value in the `class` field, you can base your expression on this and don't have to complicate yourself with the hull's geometries:

`round (count (class,group_by:=class) / count (class) * 100, 0)`

By the way, better construct your hull with a simpler expression:

``````concave_hull(
collect(
\$geometry,
group_by:="class"),
0.2
)
``````