SpatiaLite Quick Start

SpatiaLite doesn’t need to be installed [1], just get SpatiaLite and unpack it in – for example – ~/apps (tested on Ubuntu 9.4):

~$ mkdir apps
~$ cd apps
~/apps$ wget
~/apps$ tar xvfz spatialite-tools-linux-x86-2.3.1.tar.gz

Now you should be able to run it. Let’s create a test database:

~/apps$ cd ~/temp
~/temp$ ~/apps/spatialite-tools-linux-x86-2.3.1/bin/spatialite testdb.sqlite

Then we have to initialize the new database with some metadata. We need a script called init_spatialite-2.3.sql (get it from It will create the tables “geometry_columns” and “spatial_ref_sys”.

spatialite> .read '~/init_spatialite-2.3.sql' ASCII

For testing purposes, we’ll now load a shapefile into our new database. I used a Teleatlas street graph (attribute encoding iso-8859-15) and created a “streets” table:

spatialite> .loadshp ~/maps/streetgraph streets iso-8859-15

Finally, we register the geometry columns … pretty similar to PostGIS:

spatialite> UPDATE streets SET Geometry = SetSrid(Geometry,4326);
spatialite> SELECT RecoverGeometryColumn('streets','Geometry',4326,'LINESTRING',2);

Done! That’s it. Now we can view our test data in QGIS. For a longer Tutorial check



Comments are closed.

%d bloggers like this: