2

I am trying to export a shapefile of 3221 mixed POLYGON and MULTIPOLYGON geometry elements and every time, I get this same error:

enter image description here

Does anyone have any idea what's going on?

And no, this is not an exact duplicate of https://stackoverflow.com/questions/15203403 as I am working solely within QGIS.

  • What SRID (CRS) are you specifying? – Scro Dec 18 '13 at 23:14
  • Layer CRS which in my case is NAD83. Could that be the problem? – Brandon Schmidt Dec 18 '13 at 23:34
  • Are you using the DB manager for the spatialite import? – SaultDon Dec 18 '13 at 23:40
  • I do no importing...I have a shapefile vector layer loaded and via the right click menu on that layer, I am trying to save it as a SpatiaLite file. – Brandon Schmidt Dec 18 '13 at 23:43
  • @BrandonSchmidt NAD83 (EPSG 4269) should be fine. More likely the mixed geometry types are your issue, but I just wanted to rule out any CRS that is not in the default spatiaLite ref system table. – Scro Dec 18 '13 at 23:44
3

You won't be able to fix this with "Save As..." because there is no way to control the geometry type in that dialog. It only lets you enter Data Source Creation Options(-dsco) and Layer Creation Options(-lco). You will have to either use the DBManager or ogr2ogr command line.


I get this error when trying to mix geometry types when importing data to a spatialite db.

The only option I see in the DBManager is the checkbox for Create single-part geometries instead of multi-part. You can try toggling this or you may need to fallback to ogr2ogr commandline tool.

So the solution is to tell it to force all geoms to a single geometry type, either POLYGON or MULTIPOLYGON. You might want MULTIPOLYGON so that the existing multipolygons are retained.

Using ogr2ogr the option that does this is -nlt where PROMOTE_TO_MULTI looks promising and I've used it with success in the past:

-nlt type: Define the geometry type for the created layer. One of NONE, GEOMETRY, POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT, MULTIPOLYGON or MULTILINESTRING. Add "25D" to the name to get 2.5D versions. Starting with GDAL 1.10, PROMOTE_TO_MULTI can be used to automatically promote layers that mix polygon or multipolygons to multipolygons, and layers that mix linestrings or multilinestrings to multilinestrings. Can be usefull when converting shapefiles to PostGIS (and other target drivers) that implements strict checks for geometry type.

Ref:http://www.gdal.org/ogr2ogr.html

1

When trying to save a multipolygon shapefile to Spatialite (I tested polygons but I assume it is the same for other geometries) using the "save as" dialog the operation fails. Actually the fail is by ogr2ogr. As already told here when using ogr2ogr from the command line it is enough to add

-nlt MULITPOLYGON

option to get rid of the error, but in the QGIS "save as" dialog is not clear if such option can be added in the "custom options" of the same dialog.

The real issue seems that QGIS is not consistent, in fact importing into a Spatialite DB works fine for multigeometry input layers both using the Drag and Drop from the QGIS browser and using the import function of DB manager.

It also works ok using the "convert format" tool (based on ogr2ogr) of the processing toolbox (without needed to add manually any parameter).

See http://hub.qgis.org/issues/10584

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.