QGIS
QGIS copied to clipboard
Dissolve (native) algorithm: "Could not add feature with geometry type GeometryCollection..."
What is the bug or the crash?
When the output layer is a Temporary (memory) layer, then the processing algorithm "Dissolve" (native:dissolve) throws the error
Feature could not be written to Dissolved_43865acd_2535_446f_a5f1_1b9a152f67a2: Could not add feature with geometry type GeometryCollection to layer of type MultiPolygon
(of multi-type depending on the input layer type)
Could not write feature into OUTPUT
and fails to complete the task in various circumstances:
-
if the input layer doesn't contain any feature (similar to issue report #46396) or if the input layer contains only features with null geometry:
- it FAILS with default parameters
- it doesn't fail setting one or more fields and / or
- it doesn't fail setting 'SEPARATE_DISJOINT':True
-
if the input layer contains only features with empty geometry:
- it FAILS with default parameters
- it FAILS setting one or more fields
- it doesn't fail setting 'SEPARATE_DISJOINT':True even if one or more fields are set
-
if the input layer contains both features with valid geometry and features with null geometry:
- it doesn't fails in any circumstance
-
if the input layer contains both features with valid geometry and features with empty geometry (#53360):
- it doesn't fails with default parameters
- it FAILS setting one or more fields if any subset of features based on the field(s) set contains only features with empty geometry
- it doesn't fail setting 'SEPARATE_DISJOINT':True even if one or more fields are set
Steps to reproduce the issue
For example, for testing point 1 above: testlayer_1.zip for testing point 2 above: testlayer_2.zip for testing point 4 above: testlayer_4.zip (setting the field 'col1': doesn't fail; setting the field 'col2': fails)
Versions
QGIS 3.28.7 - QGIS 3.30.3 on Windows (OSGeo4W)
Supported QGIS version
- [x] I'm running a supported QGIS version according to the roadmap.
New profile
- [x] I tried with a new QGIS profile
Additional context
No response
Still happens in 3.34.
It is a really irritating misbehaviour in modeler pipelines. Same as https://github.com/qgis/QGIS/pull/47348 it would be nice to have it simply output another empty layer.
I also got this error when using Extract/Clip to clip a vector layer. Fixing the geometries and removing null geometries did not help in this. I'm baffled. Annoying behavior in modeler pipelines, indeed.
I think the wider issue is that, instead of discarding invalid geometry (i.e. 2 vertex 'polygons'), it's failing on them. No amount of fixing the geometries going into the various vector overlay tools will prevent this problem as the problem is geometry being generated from the tools themselves. (I am constantly getting these errors in the modeler when doing lots of unions, clips etc etc)
@kannes, please see https://github.com/qgis/QGIS/pull/57478.
@Saareem @timbo-barnes, please create a new issue report (if not already created) providing all the requested info and sample layer(s) with which the issue occurs.