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
tar xzf libgaiagraphics-0.4b.tar.gz
cd libgaiagraphics-0.4b
sudo make install-strip
sudo ldconfig
cd ..

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

tar xzf spatialite_gui-1.5.0-stable.tar.gz
cd spatialite_gui-1.5.0-stable
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.

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>