[GIS] QGIS 2.18.2 – Digitizing Error geometry type is not compatible with the current layer

digitizingqgis

I have an issue with digitizing lines in QGIS 2.18.2. I was using cadtools and after digitizing lines in my Lines layer on saving i get the message:

–Could not commit changes to layer (insert layer name)

Errors: ERROR: 1 feature(s) not added – geometry type is not compatible with the current layer.–

I have digitized a line in a line layer – that is certain.

I have tested without using the Cadtools and it appears that even if i use the snapping tool to digitize to a feature it throws the above error but if i just digitize a random line not using snapping then it is able to save.

Best Answer

I think you are hitting this bug. Basically, if you have a 3d point that you're line starting point is snapped to, that line becomes a LinestringZ instead of a Linestring. Of course, a LinestringZ cannot be saved in a Linestring column type so the error pops out. Under 2.14, the error is more explicit as it comes from the database side (if you're using Postgis):

PostGIS error while adding features: ERROR:  Geometry has Z dimension but column does not

Under 2.18 and Master, the error is caught by QGIS, under the error message from the question.

Here's a screenshot of the problem: enter image description here

Of course, the upper line doesn't get saved. You can see what happens by labeling your line layer with:

geom_to_wkt($geometry)