2

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 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 convex hull in batch mode? This would be ~100 new layers - could this be handled with QGIS?

4

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 at 10:17
1

Alternatively, since you are referencing SQL yourself, why not using 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>
GROUP BY
       <that_attribute>
;
  • Caveat and benefit: Using this approach the hulls are going to be recalculated on each map interaction. – bugmenot123 Aug 8 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 – ThingumaBob Aug 8 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. – bugmenot123 Aug 8 at 14:00
  • @bugmenot123 yeah I might be biased by the ways I do things ,) good to point that out! – ThingumaBob Aug 13 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.