I tried to use QGIS to create voronoi polygons from a set of points with an attribute (group
) and then merge the polygons with the same value for that attribute. (This last step is what QGIS calls Dissolve.) It worked in principle, but since the built-in voronoi algorithm produces erroneous output, I am trying alternatives, especially ST_VoronoiPolygons.
I managed to load a table of points (my_points
) into PostgreSQL. It has a geom
column (automatically created for PostGIS) and a group
column.
I read that I should use the following commands:
drop table if exists voronoi_output;
create table voronoi_output as
select ST_Dump(ST_VoronoiPolygons(ST_Collect(geom))) from my_points;
But the newly created table voronoi_output
is missing the group
column, which is needed for the next step (dissolve). How can this be fixed?
(If ST_VoronoiPolygons
would accept polylines as input, I could just feed it a bunch of polylines instead of "groups" of points. Then the "dissolve" step would not be needed), but I do not expect that to work.)
JOIN
is supposed to be the preferred way to cross-reference two tables, theST_Within
supposedly performs better thanST_Intersects
. I would also recommend to perform the 'dissolve' as part of the query.