Bug report #10584

Saving as SpatiaLite fails with "save as" dialog when input is a multi geometry

Added by Harry Clarke almost 10 years ago. Updated over 9 years ago.

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

Description

New description:

When trying to save a multipolygon shapefile to Spatialite using the "save as" dialog the operation fails. Actually the fail is by ogr2ogr. When using ogr2ogr from the command line it is enough to add

-nlt MULITPOLYGON

option, but in the "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).

It is not clear to me how that step made into the documentation as the very same issue affects QGIS down to 1.8 included (maybe in an earlier release it was ok).

---------------
Old Description:

On page 7 of the QGIS Training Manual, users are instructed to save the landuse layer as SpatialLite. In so doing, the following error was encountered, using the dataset as described in the training manual.

Export to vector file failed.
Error: Feature write errors:
Feature creation error (OGR error: sqlite3_step() failed:
landuse.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed] (19))
Only 52 of 53 features written.

A file is created in the directory, but nothing is added to the map


Related issues

Related to QGIS Application - Bug report #11597: XY columns are not exported to csv Closed 2014-11-07
Related to QGIS Application - Bug report #11542: Error when saving a shapefile as GPX Closed 2014-11-04
Related to QGIS Application - Bug report #12796: Export Spatialite point layer to CSV fails on Geometry AS_XY Closed 2015-05-21

Associated revisions

Revision 528c4cac
Added by Jürgen Fischer over 9 years ago

vector file writer: assume shapefiles contain multitype data (fixes #10584)

Revision 11c2bae7
Added by Jürgen Fischer over 9 years ago

vector file writer: scan shape file geometries instead of just assuming multi geometry types (followup 528c4cacb, refs #10584, fixes #11542, fixes #11597)

Revision 881e25ba
Added by Jürgen Fischer over 9 years ago

vector file writer: scan shape file geometries instead of just assuming multi geometry types (followup 528c4cacb, refs #10584, fixes #11542, fixes #11597)

History

#1 Updated by Giovanni Manghi almost 10 years ago

  • Status changed from Open to Feedback

#2 Updated by Harry Clarke almost 10 years ago

Yes

#3 Updated by Giovanni Manghi almost 10 years ago

Harry Clarke wrote:

Yes

I cannot confirm in qgis master, can you check please?

#4 Updated by Jürgen Fischer almost 10 years ago

  • Category set to Documentation and Help

#5 Updated by Paolo Cavallini almost 10 years ago

  • Subject changed from Saving SpatialLite fails to Saving SpatiaLite fails

#6 Updated by Giovanni Manghi over 9 years ago

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

Closing for lack of feedback.

#7 Updated by Teliph Andersson over 9 years ago

  • Status changed from Closed to Reopened

Saving a shapefile as spatialite fails for me using:
QGIS version 2.4.0-Chugiak QGIS code revision exported
Compiled against Qt 4.8.6 Running against Qt 4.8.6
Compiled against GDAL/OGR 1.10.1 Running against GDAL/OGR 1.10.1
Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version 9.4beta2 SpatiaLite Version 4.1.1
QWT Version 6.0.0-svn PROJ.4 Version 480
QScintilla2 Version

Error: Feature creation error (OGR error: sqlite3_step() failed: spatialtest.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed] (19))

Shapefile used: http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_0_countries.zip

Steps to reproduce:
- Add vector layer
- Save as... Spatialite

#8 Updated by Johannes Kroeger over 9 years ago

Reproduced here with:

QGIS version 2.4.0-Chugiak
QGIS code revision fe0a303
Compiled against Qt 4.8.6
Running against Qt 4.8.6
Compiled against GDAL/OGR 1.11.0
Running against GDAL/OGR 1.11.1
Compiled against GEOS 3.4.2-CAPI-1.8.2
Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version 9.3.5
SpatiaLite Version 4.2.0
QWT Version 6.1.0
PROJ.4 Version 480
QScintilla2 Version 2.8.

#9 Updated by Giovanni Manghi over 9 years ago

  • Subject changed from Saving SpatiaLite fails to Saving SpatiaLite fails with "save as" dialog when input is a multi geometry
  • Affected QGIS version changed from 2.2.0 to master
  • Resolution deleted (worksforme)
  • OS version deleted (8.1)
  • Operating System deleted (Windows)
  • Category changed from Documentation and Help to Vectors

#10 Updated by Giovanni Manghi over 9 years ago

I added a new description to better describe the issue.

#11 Updated by Giovanni Manghi over 9 years ago

  • Subject changed from Saving SpatiaLite fails with "save as" dialog when input is a multi geometry to Saving as SpatiaLite fails with "save as" dialog when input is a multi geometry
  • Priority changed from Normal to Severe/Regression

It is more clear now where the problem may come from:

until qgis 1.7.4 saving as "sqlite" (not spatialite, because the option was not available) and adding the custom option

SPATIALITE=YES

worked as expected. Then this option stopped to work (giving an error similar to the one decribed here or creating a non functional SL db).

This should be tagged as a regression, but given the fact that there are alternatives it will be probably downgraded.

#12 Updated by Jürgen Fischer over 9 years ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF