4

I am running into problems with saving spatialite layers in QGIS 2.18. To illustrate I am following this tutorial:

http://www.qgistutorials.com/en/docs/digitizing_basics.html

Creating a new spatialite layer works, and a new file is written, and I can set up a point, line or polygon layer within the db. But when any data is added (digtitzed) within the db (in this case to the 'road' layer, QGIS fails with the error:

Could not commit changes to layer roads

Errors: ERROR: 1 feature(s) not added.

  Provider errors:
      SQLite error: roads.geometry violates Geometry constraint [geom-type or SRID not allowed]
    SQL: INSERT INTO "roads"("geometry","pkuid","name","class") VALUES (GeomFromWKB(?, 4326),?,?,?)

It is then not possible to save the layer and the project closed without saving changes. If a layer is successfully created it has a habit of becoming invisible after a random but short period of time and cannot be located. Changing symbology, zooming to layer or selecting the area know to contain the data will fail to find the point, line or polygon.

Deleting .qgis2 folder has no affect.

Problem affects QGIS 2.18.9 in Linux (Xubuntu 16.04, 64-bit) Problem is not present in QGIS 2.14.15 in Windows (Windows 7 Ult, 64-bit)

Is there a known solution or workaround?


No, not root of the problem, or I am not following you argument. Taking your suggestion verbatim produces the same error:

Could not commit changes to layer roads

Errors: ERROR: 1 feature(s) not added.

  Provider errors:
      SQLite error: roads.linestring violates Geometry constraint [geom-type or SRID not allowed]
    SQL: INSERT INTO "roads"("linestring","pkuid","name","class") VALUES (GeomFromWKB(?, 2193),?,?,?)

And as I originally posted, this exercise works with the 'ambiguous' geometry entry in 2.14. The problem continues to occur in other geometries too (polygons, points) whatever name is given to the geometry column.

1

The issue is that your geometry column is of type 'Geometry' which is ambiguous to qgis. You need to change your dataset to be of a distinct geometry type, e.g. 'Linestring' for roads

0

I had the same error this morning and here's what I did. Right-click on the spatialite layer and export the problematic layer as a ShapeFile.

However, inspect the new ShapeFile to see if you didn't lose any attributes or geometry.

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.