Bug report #16784

Creation of MultiPolygon shapefile with QgsVectorFileWriter

Added by Luca Congedo over 7 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Geometry
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:24683

Description

Hello,

I am trying to create a multipolygon shapefile using QgsVectorFileWriter with the following code in python console:

import qgis.core as qgisCore
from PyQt5.QtCore import QVariant
crs = qgisCore.QgsCoordinateReferenceSystem("epsg:4326")
fields = qgisCore.QgsFields()
fN = "field" 
fields.append(qgisCore.QgsField(fN, QVariant.Int))
outputVector = '/home/user/Desktop/vector.shp'
qgisCore.QgsVectorFileWriter(str(outputVector), "CP1250", fields,
qgisCore.QgsWkbTypes.MultiPolygon, crs, "ESRI Shapefile")
v = qgisCore.QgsVectorLayer(outputVector, "vector", "ogr")
v.wkbType()

The type returns 3, which is not multipolygon, and I can't add a multipolygon to the layer.

Am I missing something?

Thank you.


Related issues

Related to QGIS Application - Bug report #16758: regression: adding a multi-part feature to a shapefile da... Closed 2017-06-27

Associated revisions

Revision d19ed1c6
Added by Jürgen Fischer over 7 years ago

Only convert geometries to provider type when provider does strict type checking (ie. not for shapes; fixes #16593, #16784, #16792, #16770, followup 53d90b547)

Revision ecae3c95
Added by Jürgen Fischer over 7 years ago

Only convert geometries to provider type when provider does strict type checking
(ie. not for shapes; fixes #16593, #16784, #16792, #16770;
followup 87116abd72; forward ported from d19ed1c6)

History

#1 Updated by Nyall Dawson over 7 years ago

  • Resolution set to duplicate
  • Status changed from Open to Closed

Duplicate of #16758

#2 Updated by Jürgen Fischer over 7 years ago

  • Related to Bug report #16758: regression: adding a multi-part feature to a shapefile dataset fails added

Also available in: Atom PDF