Changes between Version 13 and Version 14 of SpatiaLite
- Timestamp:
- 01/13/25 08:55:22 (4 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SpatiaLite
v13 v14 1 1 = SpatiaLite = 2 [http://www.gaia-gis.it/spatialite/ SpatiaLite] is a GIS file format based on [http://www.sqlite.org/ SQLite], which uses a single file to store multiple layers and data tables. It is an alternative format to ESRI Shapefiles, which have several legacy issues (such as storage types and lengths of column names, etc.) Furthermore it is simple to distribute and run, as there is only one file.2 [http://www.gaia-gis.it/spatialite/ SpatiaLite] is a GIS file format based on [http://www.sqlite.org/ SQLite], which stores multiple layers and data tables into a single file. It is an alternative format to ESRI Shapefiles, which have several legacy issues (such as storage types and lengths of column names, etc.) Furthermore it is simple to distribute and run, as there is only one file. 3 3 4 4 == Exporting from PostGIS to SpatiaLite == 5 5 6 Use [http://www.gdal.org/ogr2ogr.html ogr2ogr] built with [http ://www.gdal.org/ogr/drv_sqlite.html SQLite options].6 Use [http://www.gdal.org/ogr2ogr.html ogr2ogr] built with [https://gdal.org/en/latest/drivers/vector/sqlite.html SQLite support]. 7 7 8 To create the SpatiaLite file and export the first layer: 8 To create the SpatiaLite file and export a first layer: 9 9 10 {{{ 10 11 $ ogr2ogr -f SQLite -dsco SPATIALITE=yes myfile.sqlite PG:"dbname=mydb user=myuser password=mypass" myschema.mytable … … 15 16 }}} 16 17 17 To load all the tables of a schema from Postgres to Spatia lite (with or without geometry) and without the views:18 To load all the tables of a schema from Postgres to SpatiaLite (with or without geometry) and without the views: 18 19 19 20 {{{ 20 21 $ ogr2ogr --config PG_LIST_ALL_TABLES YES --config PG_SKIP_VIEWS YES -f "SQLite" mydb.sqlite -progress PG:"dbname='mydb' \ 21 active_schema=myschema schemas=myschema host='localhost' port='5432' user='myuser' password='mypass' 22 active_schema=myschema schemas=myschema host='localhost' port='5432' user='myuser' password='mypass'" -lco LAUNDER=yes \ 22 23 -dsco SPATIALITE=yes -lco SPATIAL_INDEX=yes -gt 65536 23 24 }}} 24 Some advertising: To avoid the lost of the third dimension exporting geometries you need use almost gdal 1.9.0 and spatialite library 3.0.0.[[BR]]25 Also the exportation using the last sintax described don't export any field of type integer that is also a primary key. Instead it don't lost the field26 of type TEXT that are also primary keys. To avoid this lost you should use the "single table" call.27 25 28 [[BR]] 29 To load a table (mytable) (with a geometry columns named "geometry") from a Sqlite/Spatialite (mysqlite.sqlite) into a schema (myschema) of a Postgres/Postgis, using gdal 1.9.0 and spatialite 3.0.0:[[BR]] 26 To load a table (mytable) (with a geometry columns named "geometry") from a SQLite/SpatiaLite (mysqlite.sqlite) into a schema (myschema) of a Postgres/PostGIS: 30 27 31 28 {{{ 32 ogr2ogr --config SQLITE_LIST_ALL_TABLES YES -f "PostgreSQL" PG:"dbname='mydb' active_schema=myschema schemas=myschema host='localhost' port='5432' user='myuser' password='mypass' " -overwrite -lco SCHEMA=myschema -lco GEOMETRY_NAME=geometry -lco SPATIAL_INDEX=YES mysqlite.sqlitemytable29 ogr2ogr --config SQLITE_LIST_ALL_TABLES YES -f "PostgreSQL" PG:"dbname='mydb' active_schema=myschema schemas=myschema host='localhost' port='5432' user='myuser' password='mypass'" -overwrite -lco SCHEMA=myschema -lco GEOMETRY_NAME=geometry -lco SPATIAL_INDEX=YES mysqlite.sqlite mytable 33 30 }}} 34 31 32 == PostgreSQL FDW == 33 34 A Postgres Foreign Data Wrapper for SQLite which supports PostGIS types is available [https://github.com/pgspider/sqlite_fdw on GitHub].