ST_VoronoiPolygons

更新时间:
复制 MD 格式

Returns the cells of the Voronoi diagram constructed from the vertices of a geometry.

Syntax

geometry ST_VoronoiPolygons(geometry g1, float tolerance = 0.0, geometry extend_to = NULL);

Parameters

ParameterTypeDefaultDescription
g1geometryThe input geometry whose vertices are used to build the Voronoi diagram.
tolerancefloat0.0The distance within which two vertices are treated as coincident. Set a non-zero value to improve the robustness of the algorithm.
extend_togeometryNULLThe envelope that the Voronoi diagram is extended to cover. If NULL, the diagram extends to a bounding box expanded by approximately 50% in each direction from the input geometry. If specified, the diagram covers this envelope unless it is smaller than the default envelope.

Return value

Returns a GeometryCollection of Polygon geometries. The envelope of the collection is larger than the extent of the vertices of the input geometry.

Usage notes

  • If g1 is NULL, the function returns NULL.

  • If g1 contains only one vertex, the function returns an empty GeometryCollection.

  • If the area of the envelope specified by extend_to is zero, the function returns an empty GeometryCollection.

Example

The following example shows how the output differs when extend_to 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