What I am looking for is a concave_hull-by-attribute type solution, or something that results in the same effect.
I have a multipart point layer that I want to group by attribute with minimum overlap (fig1). The Concave hull plugin does not work on multipart layers. It wants to group ALL the points on a layer together (fig2). Convex plug does accept hull-by-attribute but does not closely follow the points to the degree I need (fig3).
I have also tried breaking the multipart layer into separate layers using the `Spit` vector layer plugin but that process combines all the points to one in the attribute table. So, it cannot be used with concave-hull because there are no longer any points.
How can I make this work?
Best Answer
I developed following python-solution for my case. It should be easily applicable to your case, even without much python knowledge.
Import statements:
Importing the points, where "feature_column_name" could be something like "class_id":
Then we use a modified version of the alpha-shape function from this tutorial. It now takes a buffer value as well. I have changed the meaning of the alpha, as I find it easier to use. Large values mean that your polygon contains more points. Also, we check if the resulting polygon contains at least 90% of the points. If not or if the number of points is below 20, we return the convex hull!
We can then loop over all our different points using the following function. "features" has to be iterable. You have to know the classes of your points in advance. So "features" could for example contain the class_ids [1,3,5,...] or just be range(1234).
As we now have the polygons, we can export them:
Usage:
I used this method to produce concave hulls for roughly 2 million points in 6400 different clusters. I hope, this helps, even if I'm a year late :)