Spatialite on Ubuntu

Users of Ubuntu who want to use Spatialite for managing GIS layers are in luck. New updated packages have been released bringing to Ubuntu and derivatives all the new feature of spatialite 3.1.0.

The latest spatialite includes the following improved capabilities:

  • New functions such as ST_Expand, ST_Reverse, ST_Translate
  • Updates to several other functions
  • Uses the latest sqlite 3.7.13 with an improvement in rounding double precision numbers
  • Uses the recent geos-3.3.2
  • An easier format for using a SpatialIndex in a query

To install the suite you will need the ubuntugis-unstable repository. If you haven’t yet added that repo to your software sources, follow the instructions on this OSGeo wiki page
Then it’s just a matter of running:
sudo apt-get install --yes libspatialite spatialite-bin

This will give you the library (probably already installed if you have any GIS software at all on your system), and the CLI binary for working with spatialite data. If you’re a command line type, then you’ve got all you need to start building and querying a spatialite database. You also have the command line tools to import OSM data into a Spatialite database: spatialite_osm_raw, spatialite_osm_filter, etc. And the two utilites shp_doctor to repair shapefiles, and spatialite_tool to import and export data to/from a Spatialite database.

However, the GUI interface is another story. The ready built package is version 1.3 – very old. In fact, if you create a DB using the new CLI program, and add some data layers, it will not open in the ancient ver. 1.3 GUI program. I suggest to take a few minutes to download the sources and manually build your own spatialite_gui. Only a few standard steps in the terminal:

First you’ll need a bunch of development packages:
sudo apt-get install --yes libwxgtk2.8-dev libgeos-dev libgeos++-dev libgeotiff-dev libcairo2-dev libfreexl-dev libspatialite-dev

Now download two source packages, and unzip them in your Downloads directory. First the libgaiagraphics package:

cd ~/Downloads
wget http://www.gaia-gis.it/gaia-sins/libgaiagraphics-0.4b.tar.gz
tar xzf libgaiagraphics-0.4b.tar.gz
cd libgaiagraphics-0.4b
./configure
make
sudo make install-strip
sudo ldconfig
cd ..

Here we download the tarball from the gaia-gis.it website, unzip, then run the usual configure, make and make install commands to compile and put everything in place.
Next the GUI program itself:

wget http://www.gaia-gis.it/gaia-sins/spatialite_gui-1.5.0-stable.tar.gz
tar xzf spatialite_gui-1.5.0-stable.tar.gz
cd spatialite_gui-1.5.0-stable
./configure
make
sudo make install-strip

You might want to add an item to the applications menu, and put the icon into place. While still in the spatialite_gui-1.5.0 directory:


sudo cp gnome_resource/spatialite-gui.desktop /usr/share/applications/
sudo cp gnome_resource/spatialite-gui.png /usr/share/pixmaps/

And off you go collecting and querying spatial data.

6 thoughts on “Spatialite on Ubuntu

  1. Just worth a note that this isn’t a formal 3.1.0 based release (since it isn’t released yet).

    There will almost certainly be more features in 3.1.0 than are available now.

  2. Brad Hards :

    Just worth a note that this isn’t a formal 3.1.0 based release (since it isn’t released yet).

    There will almost certainly be more features in 3.1.0 than are available now.

    Thanks, Brad
    I “jumped the gun” because I was pleased to see Ubuntu maintainers making the effort to keep up with you and Sandro in releasing updated packages. The disappointment is the GUI, of course. I have no idea why on Ubuntu they’re stuck at spatialite-gui 1.3.0.
    By “more features” are you referring to the improved topology support?
    Cheers,
    Micha

  3. Thanks, Winston
    I’m holding off for a while with spatialite 4.0 until QGIS catches up. As you know, databases created with 4.0 cannot be opened with earlier versions. And it seems that the built in spatialite provider in QGIS is still based on 3.0, so if you use the newer spatialite to create and populate a database, it will not be usable in QGIS.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>