Bug report #21191

QGIS Buffer (native:buffer) Buffering a valid GeoPackage Pointlayer (with dissolve all option) returns invalid Geopackage Polygonlayer (where it should be Multipolygon)

Added by Andre Sch. about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:High
Assignee:Nyall Dawson
Category:Processing/QGIS
Affected QGIS version:3.4.4 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29009

Description

When buffering ('DISSOLVE':True) a valid GeoPackage Pointlayer and choosing a distance small enough for the resulting bufferlayer to have multiple parts, the resulting GeoPackage Layer (saved in the same GeoPackage) will be of Geometry Type Polygon (where it should be Multipolygon).

Problems with the resulting Layer
- The Layer (or parts of it) are dissappearing when zooming in
- The Layer cannot be used for e.g. spatial selections etc.
- qgis:checkvalidity (with GEOS) shows the whole layer as invalid
- DBManager (or copying the Geometry) shows Geometry Type Polygon (NOT Multipolygon) despite having multiple parts but only one row in the Attribute Table

Executing the fix geometry tool ("native:fixgeometries") and saving the result in the same GeoPackage results in a perfectly fine (Multipolygon)-layer.

From the history window:

processing.run("native:buffer", {'INPUT':'C:/data/bufferbug.gpkg|layername=inputpoints','DISTANCE':200,'SEGMENTS':5,'END_CAP_STYLE':0,'JOIN_STYLE':0,'MITER_LIMIT':2,'DISSOLVE':True,'OUTPUT':'ogr:dbname=\'C:/data/bufferbug.gpkg\' table=\"buffer_200m\" (geom) sql='})

processing.run("qgis:checkvalidity", {'INPUT_LAYER':'C:/data/bufferbug.gpkg|layername=buffer_200m','METHOD':2,'VALID_OUTPUT':'memory:','INVALID_OUTPUT':'memory:','ERROR_OUTPUT':'memory:'})

To reproduce the bug:
- buffer the inputpoints layer in the attached GeoPackage with 200 Meters (with everything dissolved - see processing.run from above)
(The Geopackage also includes...
- the invalid Bufferresult (buffer_200m)
- the repaired (by using "native:fixgeometries") and now valid layer (repariert)

bufferbug.gpkg - Geopackage with inputpoints, invalid result and repaired results (136 KB) Andre Sch., 2019-02-06 10:43 PM

Associated revisions

Revision f22f182b
Added by Nyall Dawson about 5 years ago

[processing] Buffer algorithm should always export multipolygon layers

We can never predict when a buffer will create a multipolygon output
(e.g. for negative buffer sizes), so ALWAYS export multipolygons

Fixes #21191

Revision f4866402
Added by Nyall Dawson about 5 years ago

[processing] Buffer algorithm should always export multipolygon layers

We can never predict when a buffer will create a multipolygon output
(e.g. for negative buffer sizes), so ALWAYS export multipolygons

Fixes #21191

(cherry picked from commit f22f182bcfd7b7f5b5d8f782f3df08ee9d705115)

History

#1 Updated by Giovanni Manghi about 5 years ago

  • Operating System deleted (Windows 7, 64 bit)

Confirmed also on Linux.

#2 Updated by Giovanni Manghi about 5 years ago

  • Priority changed from Normal to High

Tagging as high as the results are invalid.

#3 Updated by Nyall Dawson about 5 years ago

  • Assignee set to Nyall Dawson

#4 Updated by Nyall Dawson about 5 years ago

  • Status changed from Open to In Progress

#5 Updated by Nyall Dawson about 5 years ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

Also available in: Atom PDF