Changes between Version 13 and Version 14 of SpatiaLite


Ignore:
Timestamp:
01/13/25 08:55:22 (4 days ago)
Author:
lnicola
Comment:

Clean up old instructions and add Postgres FDW

Legend:

Unmodified
Added
Removed
Modified
  • SpatiaLite

    v13 v14  
    11= 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.
    33
    44== Exporting from PostGIS to SpatiaLite ==
    55
    6 Use [http://www.gdal.org/ogr2ogr.html ogr2ogr] built with [http://www.gdal.org/ogr/drv_sqlite.html SQLite options].
     6Use [http://www.gdal.org/ogr2ogr.html ogr2ogr] built with [https://gdal.org/en/latest/drivers/vector/sqlite.html SQLite support].
    77
    8 To create the SpatiaLite file and export the first layer:
     8To create the SpatiaLite file and export a first layer:
     9
    910{{{
    1011$ ogr2ogr -f SQLite -dsco SPATIALITE=yes myfile.sqlite PG:"dbname=mydb user=myuser password=mypass" myschema.mytable
     
    1516}}}
    1617
    17 To load all the tables of a schema from Postgres to Spatialite (with or without geometry) and without the views:
     18To load all the tables of a schema from Postgres to SpatiaLite (with or without geometry) and without the views:
    1819
    1920{{{
    2021$ 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' " -lco LAUNDER=yes \
     22  active_schema=myschema schemas=myschema host='localhost' port='5432' user='myuser' password='mypass'" -lco LAUNDER=yes \
    2223  -dsco SPATIALITE=yes -lco SPATIAL_INDEX=yes -gt 65536
    2324}}}
    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 field
    26 of type TEXT that are also primary keys. To avoid this lost you should use the "single table" call.
    2725
    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]]
     26To load a table (mytable) (with a geometry columns named "geometry") from a SQLite/SpatiaLite (mysqlite.sqlite) into a schema (myschema) of a Postgres/PostGIS:
    3027
    3128{{{
    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.sqlite mytable
     29ogr2ogr --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
    3330}}}
    3431
     32== PostgreSQL FDW ==
     33
     34A Postgres Foreign Data Wrapper for SQLite which supports PostGIS types is available [https://github.com/pgspider/sqlite_fdw on GitHub].