Fork me on GitHub

ST_Voronoi

Signatures

-- Return type: geometry
ST_VORONOI(THE_GEOM MULTIPOINTS,OUT_DIMENSION INTEGER)
ST_VORONOI(THE_GEOM MULTIPOINTS,OUT_DIMENSION INTEGER,ENVELOPE POLYGON)

ST_VORONOI(THE_GEOM MULTIPOLYGON)
ST_VORONOI(THE_GEOM MULTIPOLYGON,OUT_DIMENSION INTEGER)
ST_VORONOI(THE_GEOM MULTIPOLYGON,OUT_DIMENSION INTEGER,ENVELOPE POLYGON)
ST_VORONOI(THE_GEOM MULTIPOINTS)

Description

Create Voronoi diagram from a set of points or a delaunay mesh.

OUT_DIMENSION Geometry dimension of voronoi returned:

  • 0 for voronoi vertex (circumcenter of delaunay triangles)
  • 1 for voronoi edges
  • 2 (default) for voronoi polygons

MULTIPOINT input

If the input is a MULTIPOINT then a QuadEdge delaunay graph is produced internally with a minimal envelope. At the final step the voronoi polygons/lines/vertex are produced. Z values are ignored.

MULTIPOLYGON input

If the input is a MULTIPOLYGON made of triangles mesh. Using geometry coordinates this function compute the triangle neighbors of the provided mesh.

Examples

-- Create input data point cloud
drop table if exists pts;
create table pts as select ST_MakePoint(A.X + (COS(B.X)), B.X - (SIN(A.X)), ROUND(LOG10(1 + A.X * (5 * B.X)),2)) THE_GEOM from SYSTEM_RANGE(0,50) A,SYSTEM_RANGE(30,50) B;

Create classic voronoi polygons with default envelope. (Z values are not kept.)

drop table if exists voro;
create table voro as select ST_VORONOI(ST_ACCUM(the_geom)) the_geom from PTS;

Create voronoi polygons with Z values with input points as envelope.Then create a new table with one voronoi polygon per row.

drop table if exists voro;
create table voro as select ST_VORONOI(ST_DELAUNAY(ST_ACCUM(the_geom)), 2 , ST_ACCUM(the_geom)) the_geom from PTS;
drop table if exists voroexpl;
create table voroexpl as select * from st_explode('voro');

Use case

A specific use case, using ST_Voronoi function is avalaible HERE.

See also