<div dir="ltr"><div>Hello</div><div><br></div><div>My name is Javier Sanchez and I'm 
the developer of a QGIS based standalone application to convert Spanish 
Cadastre data to OpenStreetMap format [1]. I'm trying to port this app 
from QGIS 2 to 3 and I would like this to work also with the previous 
version.</div><div><br></div><div>In QGIS 2.x, I was able to write a 
shapefile with a mixed set of polygons and multipolygons geometries. Now
 in QGIS 3.x I can't. Maybe this is a GDAL issue. Probably the last 
behaviour is the correct 
one. But is there any way in QGIS 3 to create a shapefile mixing 
polygons with multipolygons?<br><br>Here is an example code to illustrate what I meant:<br><br>        crs = QgsCoordinateReferenceSystem(3<wbr>2628)<br>        fn = 'xxx.shp'<br>        w = PolygonLayer.create_shp(fn, crs)<br>        p = [[QgsPoint(0,0), QgsPoint(1,0), QgsPoint(1,1), QgsPoint(0,0)]]<br>        mp = [[[QgsPoint(2,0), QgsPoint(3,0), QgsPoint(3,1), QgsPoint(2,0)]], <br>              [[QgsPoint(4,0), QgsPoint(5,0), QgsPoint(5,1), QgsPoint(4,0)]]]<br>        f1 = QgsFeature(QgsFields())<br>        g1 = QgsGeometry().fromPolygon(p)<br>        f1.setGeometry(g1)<br>        w.addFeature(f1)<br>        f2 = QgsFeature(QgsFields())<br>        g2 = QgsGeometry().fromMultiPolygon<wbr>(mp)<br>        f2.setGeometry(g2)<br>        w.addFeature(f2)<br>        del(w)<br>        l = QgsVectorLayer(fn, 'test', 'ogr')<br>        for f in l.getFeatures():<br>            g = f.geometry()<br>            print(g.isMultipart())<br><br></div><div>When I run this in QGIS 2, the output is:<br><br></div><div>    False<br></div><div>    True<br></div><div><br></div><div>When
 I run the same example in QGIS 3.x (replacing fromPolygon with 
fromPolygonXY and fromMultiPolygon with fromMultiPolygonXY), the output 
instead is:<br></div><div><br><div>    True<br></div><div>    True<br></div><div><br></div>The
 writer converts g1 from polygon to multipolygon and every geometry in 
the resulting shapefile have the same type while before I had a bunch of
 multipart and singlepart geometries.<br><br></div><div></div><div>Regards, Javier<br></div><div><br></div><div>[1] <a href="https://github.com/OSM-es/CatAtom2Osm" target="_blank">https://github.com/OSM-es/CatA<wbr>tom2Osm</a></div><br></div>