Bug report #15487

"Create single-part geometries instead of multi-part" option broken

Added by R. R. over 4 years ago. Updated almost 4 years ago.

Status:Closed
Priority:Normal
Assignee:Sandro Santilli
Category:DB Manager
Affected QGIS version:2.16.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:No Copied to github as #:23411

Description

When importing multi-part geometries the "Create single-part geometries instead of multi-part" option throws an error:

Error 7
Feature write errors:
Creation error for features from #0 to #0. Provider errors was:
PostGIS error while adding features: FEHLER: Geometry type (MultiPolygon) does not match column type (Polygon)

error_7.png (19.3 KB) R. R., 2016-08-24 11:48 PM

History

#1 Updated by Tudor Bărăscu over 4 years ago

I also just encountered this issue.
Steps to reproduce:
- Download natural earth coutntries data (http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip
and try to import as simple features (as multipart it works)
If you try the sqlite file http://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip it won't work for either options (create as simple or as multipart features)
- The error is the same

#2 Updated by Sandro Santilli about 4 years ago

  • Status changed from Open to Feedback
  • Assignee set to Sandro Santilli

The shapefile contains record with multi-geometries, what would you expect from the "Create single-part geometries instead of multi-part" option ?

The option is passed to QgsVectorLayerImport which does not document the semantic of that option ("forceSinglePartGeometryType").

Also, why is this marked as Severe/Regression ?

#3 Updated by R. R. about 4 years ago

As far as I remember former QGIS versions have converted the multipart geometries into singlepart geometries instead of throwing an error. I'll test this later.

#4 Updated by Sandro Santilli about 4 years ago

Reinhard let me know what you find, and what does it mean to "convert a multipart into singlepart" (augmenting the number of records ? picking just the first component ?)

#5 Updated by R. R. about 4 years ago

I must have been wrong, since QGIS 2.8.1 throws the same error. To me, 'Create single-part geometries instead of multi-part' in the DB-Manager should work in the same way as 'Multipart to singleparts' in the processing toolbox.

#6 Updated by Sandro Santilli about 4 years ago

  • Priority changed from Severe/Regression to Normal

How does "Multipart to singleparts" work, within processing ? (downgrading from Severe/Regression to Normal)

#7 Updated by R. R. about 4 years ago

'Multipart to singleparts' converts a multipart feature with 'n' geometries to 'n' singlepart features.

#8 Updated by Sandro Santilli about 4 years ago

I don't think "Create single-part geometries instead of multi-part" was ever meant to apply any conversion.
The "Import vector to PostGIS" processing tool might be closer, having a "Promote to multipart" switch.
Can you please try how that processing tools behave if you uncheck the "Promote to multipart" setting ?

#9 Updated by Giovanni Manghi almost 4 years ago

  • Resolution set to invalid
  • Status changed from Feedback to Closed

Sandro Santilli wrote:

I don't think "Create single-part geometries instead of multi-part" was ever meant to apply any conversion.

That is correct. The wording is somehow misleading, but the option work as expected:

  • by default any vector is imported into a MULTI* table even if the input layer has no multipart geometries
  • if the input layer has no multipart geometries then this option allows to import it into a POINT/LINESTRING/POLYGON table (not MULTI*)
  • if the input layer has multipart geometries than the option cannot be used and will return the described error

Also available in: Atom PDF