This topic describes the ST_VoronoiPolygons function. This function computes a two-dimensional Voronoi diagram by using the vertices of a geometry object.

Syntax

geometry  ST_VoronoiPolygons(geometry  g1, float  tolerance, geometry  extend_to);

Parameters

Parameter Description
g1 The geometry object that you want to specify.
tolerance The tolerance. Default value: 0.0. If the distance between the two vertices is smaller than the value of the tolerance parameter, the two vertices are coincident. You can specify a value that is not zero for the tolerance parameter to increase the robustness of the algorithm.
extend_to The extended envelope. Default value: null. If you set this parameter to null, the default envelope is the bounding box that is extended by approximately 50% in each direction of the specified geometry object. If you specify this parameter, the Voronoi diagram is extended to cover the extended envelope, unless the extended envelope is smaller than the default envelope.

Description

  • If the return value is a GeometryCollection object of Polygons, the extended envelope is larger than the extent of the vertices of the specified geometry object.
  • If the specified geometry object is NULL, the ST_VoronoiPolygons function returns NULL.
  • If the specified geometry object contains only one vertex, the ST_VoronoiPolygons function returns an empty GeometryCollection object. If the specified geometry object contains only one vertex, the ST_VoronoiPolygons function returns an empty GeometryCollection object.
  • If the area of the extended envelope that is specified by the extend_to parameter is zero, the ST_VoronoiPolygons function returns an empty GeometryCollection object.

Examples

The following example shows the differences between the return results that are obtained when the extend_to parameter is set to different values:
SELECT ST_VoronoiPolygons(g,0,e),g,e
             from (select ST_Buffer('LINESTRING(0 0,3 0,3 3)'::geometry,1,'join=mitre endcap=square') as g,
                    ST_Buffer('POINT(-1 -1)'::geometry,10) as e) as t;
12