1

In QGIS I have a spatialite DB full of roads. I'd like to do a Difference operation (Vector > Geometry Tools > Difference) with another layer in order to keep roads only available in a given zone. The difference works fine but once I try to save that new layer to a Spatialite DB I get OGR error saying that it can't insert GEOMETRYCOLLECTION where a MULTILINESTRING is expected.

I don't know how to fix that and what to do.

enter image description here

enter image description here

enter image description here


Following the @she_weeds' answer it was suggested to try saving that layer to another format and then to Spatialite. Saving it to GeoJSON worked, I could convert it to Spatialite after that and import it to my QGIS project (even if the auto-import didn't worked at first).

Even if everything works now using this workaround, I will update QGIS to latest version too.

  • 1
    Please show the dialog you used just before you get these errors. – bugmenot123 Nov 21 '18 at 10:53
  • @bugmenot123 hey thanks for your suggestion, I've edited the question and added two screenshots. I hope it helps. Thanks. – lvictorino Nov 21 '18 at 13:02
  • Does the layer TEST2 already exist in that spatialite file? – bugmenot123 Nov 21 '18 at 14:33
  • Nope. Should it? – lvictorino Nov 21 '18 at 14:37
2

Try forcing the geometry by selecting Linestring as the geometry type and checking 'Force multi-type' in the dialog box you have shared.

  • Thanks for your answer... Unfortunately it ends up with the same error: > Feature creation error (OGR error: Cannot insert feature with geometry of type GEOMETRYCOLLECTION in column GEOMETRY. Type MULTILINESTRING expected) – lvictorino Nov 21 '18 at 13:18
  • Bit of a long shot but I notice you're using QGIS 2.18, is it possible for you to try it with 3.x? I have done differences in virtual layers before that behaved as geometry collections in 2.x but would load as multipolygons in 3.x. – she_weeds Nov 21 '18 at 13:21
  • Also I take it you have retried the above after dropping the table and recreating it by saving the layer in QGIS (assuming this is a new table and that you are not appending data to an existing one) – she_weeds Nov 21 '18 at 13:23
  • Saving it in QGIS? how (sorry I'm new here). Is it with a "save as.." or a simple "save project" in qgis is enough? For now it's not saved, it's the result of the difference tool. So its layer source is defined as MultiLineString?uuid=73d12133-649c-4e9c-bc97-2ed45b044734&crs=EPSG:4326&field=.... What would you suggest to save it? (If it still fails after that I'll update my QGIS). Thanks for your time and help on this! – lvictorino Nov 21 '18 at 13:26
  • Just the "save as" - maybe save it as a completely different table (not overwriting or appending to TEST2) . I have tried recreating a similar scenario to yours with a multilinestring temp layer as the result of a difference from a polygon and line, layer source similar to yours, and saved it as a spatialite table in a new database using QGIS 2.18.15 without any errors (having forced the multilinestring geometry as I described)... – she_weeds Nov 21 '18 at 13:33

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.