I am writing a python processing script in QGIS 3. In it, I have polygon geometry objects stored in a list polygonGeoms and I want to dissolve all of it into one geometry. However, when calling the function QgsGeometry.unaryUnion(polygonGeoms), it returns a null geometry. I've used the unaryUnion function before so I know that it should give me the result I want.

To investigate, I exported the geometries as a temporary shapefile layer. And when I use the Dissolve tool in QGIS 3, it also returns a null feature. The Dissolve tool works on the shapefile when I use QGIS 2.18 though, for some reason.

This is a link to the sample shapefile.


I did not find any issue with your data. Unary union is working fine at my end

from qgis.core import *
from qgis.gui import *
vl = iface.activeLayer()
geoms = [f.geometry() for f in vl.getFeatures()]
g = QgsGeometry.unaryUnion(geoms)

enter image description here

  • 1
    Can you add the code as text to your answer? – BERA Apr 20 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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