Saturday 14 May 2016

Saving multiple layers from QGIS to SpatiaLite database?


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.




Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...