I have a layer with lots of (spatially grouped) lines - lines belonging to a group share the same value in a field. I would like to create convex hulls around each of these groups using QGIS 3.8.

I learned that Vector Geometry->Convex hull is not attribute specific and the batch functionality works with a set of layers, not specific on attributes.

I tried the model builder, but I'm struggling - I would need to first create a set of objects grouped by that attribute (in SQL it would be something like GROUP BY), and then something like a "do convex hull for each in set".

Or create a number of new layers based on the attribute and use a convex hull in batch mode? This would be ~100 new layers - could this be handled with QGIS?

3 Answers 3


There is another Convex Hull function in the "Vector geometry" -" "Minimum bounding geometry" tool. That one allows you to specify a field by with the geometries should be grouped.

  • 1
    I didn't know this tool. It solves my problem and is able to not only produce convex hull but also bounding box etc.
    – roland
    Aug 8, 2019 at 10:17

Alternatively, since you are referencing SQL yourself, why not use the natively supported SpatiaLite dialect?

Get familiar with Virtual Layers and the DB Manager if not already, and run sth. like

SELECT <that_attribute>,
       ST_ConcaveHull(ST_Collect(geometry)) AS geometry
FROM   <layer_name>
  • Caveat and benefit: Using this approach the hulls are going to be recalculated on each map interaction. Aug 8, 2019 at 12:28
  • @bugmenot123 I don't see a caveat; you have the ultimate flexibility of spatial SQL: alter output with a simple change of functions or their parameters, no limit to what attributes/values you group by, and if you want persistent results (and only then, in contrast to the use of the built-in tools), just export to e.g. file
    – geozelot
    Aug 8, 2019 at 13:30
  • It can become very slow. The user might not be aware that it is not a one-time operation but constantly recalculated. If their data is static, it is not really necessary. Don't get me wrong, this approach is awesome IF you know the caveats. Aug 8, 2019 at 14:00
  • @bugmenot123 yeah I might be biased by the ways I do things ,) good to point that out!
    – geozelot
    Aug 13, 2019 at 16:36

You can create a convex hull based on an attribute using QGIS expressions with "Geometry Generator" or "Geometry by Expression" (see here for details about both options). Use this expression:

convex_hull(collect($geometry, group_by:="attribute_name"))

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.