3

I am starting to work with SpatiaLite 4.3 in an empty database. SpatiaLite requires a number of meta-data tables, where it stores information about geometry fields. For previous versions there are SQL scripts that create and initialise these tables; for instance, the release page for version 2.3 lists a script named init_spatialite-2.3.sql.

I have not been able to find a similar script for version 4.3. Is the database initialised differently in this version?

2

1 Answer 1

6

With current SpatiaLite versions the spatial metadata tables are created with SQL function InitSpatialMetadata(). The usage is documented in http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html

Creates the geometry_columns and spatial_ref_sys metadata tables the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE

  • if the optional argument transaction is set to TRUE the whole operation will be handled as a single Transaction (faster): the > default setting is transaction=FALSE (slower, but safer).
  • if the optional argument mode is not specified then any possible ESPG SRID definition will be inserted into the spatial_ref_sys table.
  • if the mode arg 'WGS84' (alias 'WGS84_ONLY') is specified, then only WGS84-related EPSG SRIDs will be inserted
  • if the mode arg 'NONE' (alias 'EMPTY') is specified, no EPSG SRID will be inserted at all

Single transaction is much faster, about 1 second vs. one minute.

select InitSpatialMetadata(1);

If the size of the database is critical then using mode WGS84 or NONE will save about 5 megabytes but then you may need to insert the SRID definitions that you need later with InsertEpsgSrid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.