Background:
At 3.14.16, I'm trying to learn a little more about Geometry Generator, in this case convex hull. I created a simple test point layer with six points. I then used Geometry Generator with the expression convex_hull($geometry), expecting an outline hull to display. However, none appeared, as shown in the screenshot below. Only the original points appear.
In my search for a solution, I came across this SE GIS post, where convexHull($geometry) was successfully used. Unfortunately, that expression did not result in a outline for my points.
Question:
How do I display a convex hull around a point layer using Geometry Generator?
2 Answers 2
You need to select Polygon/ MultiPolygon geometry type for the geometry generator symbol layer, and add the collect
function to your expression:
convex_hull(collect($geometry))
Update August 2023:
the $geometry
function is now deprecated in favor of the @geometry
variable.
So:
convex_hull(collect(@geometry))
-
1FYI, now,
$geometry
is deprecated. You should switch to@geometry
insteadetrimaille– etrimaille2023年08月11日 16:49:04 +00:00Commented Aug 11, 2023 at 16:49 -
@etrimaille, thanks for the reminder- answer updated.Ben W– Ben W2023年08月12日 05:09:03 +00:00Commented Aug 12, 2023 at 5:09
The correct answer is the one accepted.
Just adding another one if you are looking to do it with a common attribute :
convex_hull(collect (@geometry, group_by:="name_of_attribute"))
convex hull with a common attribute
A mix between Geometry generator - classify objects in QGIS and the accepted answer here
Just to share, it took me some time to see we could give a group by in the collect
expression.
Explore related questions
See similar questions with these tags.