2

I am using the Delaunay triangulation on a set of points, trying to isolate clusters of points in a regular pattern.

My first experience with using the qhull.Delaunay object so bear with me...

from scipy.spatial import Delaunay
tri = Delaunay(array)

Currently looks like:

Delaunay output

and I've found I can print (tri.simplices) to get the list. I want to isolate only those that are in the obvious clusters, which I imagine could be done by removing those with line length or volume over a certain threshold, but I'm unsure how to manipulate the result to do this?

Cate
  • 431
  • 1
  • 7
  • 22

1 Answers1

2

Found the answer - posting in case it is useful for others.

The Delaunay output gives you the list of the coordinates for each point, and a nested list of which three points form each triangle.

To access their area, first you convert this into a list of Shapely polygons, then your polygons are your oyster.

from shapely.geometry.polygon import Polygon

coord_groups = [tri.points[x] for x in tri.simplices]
polygons = [Polygon(x) for x in coord_groups]

#area of the first polygon
polygons[0].area
Cate
  • 431
  • 1
  • 7
  • 22
  • CAn you provide your whole code that you used to figure it out? i would appreciate it! i am trying to solve a very similar problem [here][1] [1]: https://stackoverflow.com/questions/63608352/eliminating-some-edges-in-a-python-plotly-created-traingulation-mesh-from-a-poin – Kathan Vyas Aug 27 '20 at 03:29