(edit 2019) ST_VoronoiPolygons available since PostGIS v2.3!
With PostGIS 2.1+ we can use ST_DelaunayTriangles() to generate a Delaunay triangulation, that is a dual graph of its Voronoi diagram, and, in theory, they have an exact and reversible conversion.
Does any safe SQL-standard script with an optimized algorithm exist for this PostGIS2 Delaunay-to-Voronoi conversion?
Best Answer
The following query appears to do a reasonable set of voronoi polygons starting from the Delaunay Triangles.
I'm not a big Postgres user, so it can probably be improved quite a bit.
This produces the following set of polygons for the sample points included in the query
Query Explanation
Step 1
Create the Delaunay Triangles from the input geometries
Step 2
Decompose the triangle nodes and make edges can be made. I think there should be a better way to get the edges, but I didn't find one.
Step 3
Build the circumscribed circles for each triangle and find the centroid
The
Edges
CTE outputs each edge and the id(path) of the triangle it belongs to.Step 4
'Outer Join' the 'Edges' table to itself where there are equal edges for different triangles (interior edges).
Where there is a common edge draw a line between the respective centroids
Where the edge is not joined (exterior) draw a line from the centroid through the centre of the edge. Only do this if the centroid of the circle is inside the set of triangles.
Step 5
Get the convex hull for the drawn lines as a line. Union up and merge all the lines. Node the line set so that we have a topological set that can be polygonized.