I am trying to load this query result using PostGIS 2.5 connection in QGIS 3.4, QGIS 2.18.

SELECT ST_VoronoiPolygons(geom) As geom FROM (SELECT 'MULTIPOINT (50 30, 60 30, 100 100,10 150, 110 120)'::geometry As geom ) As g;

Getting the error of the vector layer GeometryCollection result as Raster Layer in QGIS.

Results =>

enter image description here

I have tried these PostGIS functions to verify results,

  1. https://postgis.net/docs/ST_IsValid.html
  2. https://postgis.net/docs/ST_MakeValid.html
  3. https://postgis.net/docs/ST_IsValidReason.html

I have also applied ST_AsGeoJSON and ST_AsText, results is GeometryCollection, and valid.

I have imported the GeoJSON in https://mapshaper.org/, it's okay.

After extracting/dumping the Features from GeometryCollection with following functions it's working fine.

  1. ST_CollectionExtract with Polygon selection.
  2. ST_Dump.

Why QGIS Load GeometryCollection vector query result as a raster layer? Is there any method available under QGIS to load GeometryCollection?

1 Answer 1


Qgis does not like GeometryCollection, you should convert geometry collection result of ST_VoronoiPolygons to MultiPolygon using ST_CollectionExtract. For example if you have a point layer to generate voronoi cells:

with p as (
    select ST_Union(geom) as geom from you_point_layer
select 1 as id, 
ST_CollectionExtract(ST_VoronoiPolygons(geom), 3) as geom from p;

The second parameter of ST_CollectionExtract is the geometry type to extract (3 = polygon). The result is one multipolygon geometry. Next picture shows how to use it in DB Manager for a point layer to get voronoi cells (varos is my point layer)

Query in DB Manager

And loading it into QGIS:

enter image description here

  • I have already mentioned the ST_CollectionExtract function, it's working fine. Mar 4, 2019 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.