10

Each time I save a layer from QGIS as a spatialite it insists on creating a new db ( if you select a existing db you are asked whether to cancel or replace).

I want to package all the layers of a project into a single spatialite db for distribution.

I figure that I can use native sqlite tools to combine the layers from the individual files but it would be nice not to have to do so.

11

You can create an empty SpatiaLite database using Layer > Create Layer > New SpatiaLite Layer. Once you've done so, it will appear in the DB Manager (an included plugin; enable from the plugin manager if it is disabled). Alternatively, if you have an existing database you would like to add layers to, add it with Layer > Add Layer > Add Spatialite Layer (not with Add Vector Layer). This will make the SpatiaLite database appear in the DB Manager

Once you have done either of the above, you can use the DB Manager to import any layer loaded in QGIS, of any origin, to the SpatiaLite DB.

I believe this to be a better option than using Qspatialite, as DB Manager is a core QGIS plugin and maintained by the QGIS team.

  • How do you import a layer to the SpatialLite DB using the DB Manager? I tired it but when using simply the "Import layer/file" menu the geometries are lost. – Bushroot Jan 31 '18 at 20:06
7

give the qspatialite plugin a try (https://plugins.qgis.org/plugins/QspatiaLite/)

(Create empty db, now you can select all your layers and add at one go. see screenshot 1)

Saving layers into  db

Retrieving layers from db

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.