SpatiaLite: Difference between revisions
m (→Export) |
(Updated the explanation how to export a grass vector layer to a spatialite database) |
||
Line 1: | Line 1: | ||
== Spatialite == | == Spatialite == | ||
A {{Wikipedia|SQLite}} database with geospatial extensions, much list [[PostGIS]] is to {{Wikipedia|PostgreSQL}}. | A {{Wikipedia|SQLite}} database with geospatial extensions, much list [[PostGIS]] is to {{Wikipedia|PostgreSQL}}. To export a layer to a Spatialite database with v.out.ogr, use the SQLite [[OGR]] driver and set the SPATIALITE data creation option to "yes". | ||
==== New database ==== | |||
=== | v.out.ogr in=mymap output=mydbase.sqlite format=SQLite \ | ||
type=area dsco='SPATIALITE=yes' output_layer="mymap" | |||
==== Existing spatialite database ==== | |||
Note that you need to use --overwrite, otherwise v.out.ogr will complain that the output already exists. Using --overwrite should maintain the existing tables in the spatialite database. However, it is strongly suggested to run this on a copy of the database, or make sure you have a recent backup. | |||
v.out.ogr -u in=mymap output=mydbase.sqlite format=SQLite \ | |||
type=area dsco='SPATIALITE=yes' output_layer="mymap" --overwrite | |||
==== Using QGIS (1) ==== | |||
An alternate way is to load the layer in QGIS's GRASS toolbox, then right click on the layer name and select "Save As...". | |||
==== Using QGIS (2) ==== | |||
Open the layer in QGIS using the browser panel. Next, open the spatialite database in the QGIS DB manager and use the 'import layer' option to import the grass vector layer you just opened in QGIS into the spatialite database. |
Revision as of 14:31, 1 February 2017
Spatialite
A SQLite database with geospatial extensions, much list PostGIS is to PostgreSQL. To export a layer to a Spatialite database with v.out.ogr, use the SQLite OGR driver and set the SPATIALITE data creation option to "yes".
New database
v.out.ogr in=mymap output=mydbase.sqlite format=SQLite \ type=area dsco='SPATIALITE=yes' output_layer="mymap"
Existing spatialite database
Note that you need to use --overwrite, otherwise v.out.ogr will complain that the output already exists. Using --overwrite should maintain the existing tables in the spatialite database. However, it is strongly suggested to run this on a copy of the database, or make sure you have a recent backup.
v.out.ogr -u in=mymap output=mydbase.sqlite format=SQLite \ type=area dsco='SPATIALITE=yes' output_layer="mymap" --overwrite
Using QGIS (1)
An alternate way is to load the layer in QGIS's GRASS toolbox, then right click on the layer name and select "Save As...".
Using QGIS (2)
Open the layer in QGIS using the browser panel. Next, open the spatialite database in the QGIS DB manager and use the 'import layer' option to import the grass vector layer you just opened in QGIS into the spatialite database.