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
| Parameter | Type | Default | Description |
|---|---|---|---|
g1 | geometry | — | The input geometry whose vertices are used to build the Voronoi diagram. |
tolerance | float | 0.0 | The distance within which two vertices are treated as coincident. Set a non-zero value to improve the robustness of the algorithm. |
extend_to | geometry | NULL | The 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
g1is NULL, the function returns NULL.If
g1contains only one vertex, the function returns an emptyGeometryCollection.If the area of the envelope specified by
extend_tois zero, the function returns an emptyGeometryCollection.
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;

该文章对您有帮助吗?