I have a shapefile with one layer. I can open it with QGIS. Now I want to convert this shapefile or layer to Spatialite database.
How can I do it? Is it possible to do with QGIS?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have a shapefile with one layer. I can open it with QGIS. Now I want to convert this shapefile or layer to Spatialite database.
How can I do it? Is it possible to do with QGIS?
Several options!
Within QGIS, you can "File|Save as" the shapefile directly as a spatialite database; the limitation here is that you can make a database with only one shapefile.
You can use the command line spatialite_tool
to load and manage shapefiles (tutorial here).
It is really worth exploring the spatialite-gui and spatialite-gis standalone applications, which let you view and modify data directly. In the gui app, create a new database (second toolbar button), then load a shapefile (green world icon with arrow) - you must know and input the SRID of the shapefile in the resulting dialog. The advantage here is that you can easily add multiple shapefiles, and build a large database.
Yes it can be done with QGis.
Using the QSpatiaLite Plugin
"Manage your SpatiaLite databases within QGis"
After installing the plugin you can run it.
You will receive a series of messages/errors stating that you do not have a spatialite db.
it will step you through getting one installed (choose a location for the file) and finally converting it to spatial.
Then in this dialog you can import your QGis layer.
Then: you don't really need this. It only works to create a new db.
From the QGIS menu
Layer | Save As...
From the QGIS 'Save vector layer as...' dialog box
Choose Spatialite from the Format drop down list.
You can right-click the layer and select "save layer as..." and choose spatiaLite as your format. Your only option there is to create a new database, i.e. you cannot add it to an existing database.
The QspatiaLite plugin adds a lot of functionality to QGIS, so give that a try as well.
There is a GUI application called spatialite-gui that allows you to import shapefiles and build spatial indexes.