ST_VoronoiPolygons computes a two-dimensional Voronoi diagram from the vertices of a geometry object and returns the result as a GeometryCollection of polygons.
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 compute the Voronoi diagram. |
tolerance | float | 0.0 | The snap distance. Vertices within this distance of each other are treated as coincident. A non-zero value improves the robustness of the algorithm. |
extend_to | geometry | NULL | The envelope to which the Voronoi diagram is extended. If NULL, the diagram extends to a bounding box expanded by approximately 50% in each direction around the input geometry. If specified, the diagram extends to cover this envelope, unless the envelope is smaller than the default. |
Return value behavior
Returns a
GeometryCollectionof polygons. The output envelope is larger than the extent of the input vertices.Returns
NULLifg1isNULL.Returns an empty
GeometryCollectionifg1contains only one vertex.Returns an empty
GeometryCollectionif the area of theextend_toenvelope is zero.
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;Result with default envelope:

Result with custom envelope:

该文章对您有帮助吗?