<div dir="ltr">Hello Javier,<br><div>just force the multipolygon behaviour.</div><div>As you say it's a GDAL refinement, just use a Layer Creation Option (-lco). As per the docs (<a href="http://www.gdal.org/drv_shapefile.html">http://www.gdal.org/drv_shapefile.html</a><span class="seweij5nstljm1f"></span><span class="sew9s89hbg7rm4r"></span>):</div><div><ul style="color:rgb(0,0,0);font-family:-webkit-standard"><li><b>SHPT=type</b>: Override the type of shapefile created. Can be one of NULL for a simple .dbf file with no .shp file, POINT, ARC, POLYGON or MULTIPOINT for 2D; POINTZ, ARCZ, POLYGONZ, MULTIPOINTZ or MULTIPATCH for 3D; POINTM, ARCM, POLYGONM or MULTIPOINTM for measured geometries; and POINTZM, ARCZM, POLYGONZM or MULTIPOINTZM for 3D measured geometries. The measure support was added in GDAL 2.1. MULTIPATCH files are supported since GDAL 2.2.</li></ul></div><div class="gmail_extra">I think there are consequences, it will be necessary to know if there are multipolygons in cadastral parcels. This is almost always the case if you have an entire map, but it could be necessary to scan data or at least to issue a GDAL_SQL query to detect it.</div><div class="gmail_extra"><br></div><div class="gmail_extra">c</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 29, 2018 at 3:39 PM, Javier Sánchez Portero <span dir="ltr"><<a href="mailto:javiersanp@gmail.com" target="_blank">javiersanp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
<br>______________________________<wbr>_________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--------------------------------------------------------------------------<br>Carlo A. Bertelli<br>   Charta servizi e sistemi per il territorio e la storia ambientale srl <br>          Dipendenze del palazzo Doria, <br>          vc. alla Chiesa della Maddalena 9/2 16124      Genova (Italy)<br>          tel./fax +39(0)10 2475439  +39 0108566195  mobile:+39 393 1590711<br>   e-mail: <a href="mailto:bertelli@chartasrl.eu" target="_blank">bertelli@chartasrl.eu</a>      <a href="http://www.chartasrl.eu" target="_blank">http://www.chartasrl.eu</a><br>--------------------------------------------------------------------------<br><br><br><br></div>
</div></div>