8/8/2013 - 5:24 AM

how to install pyspatialite

how to install pyspatialite

Install prerequisite package dependencies

From http://elgis.argeo.org/repos/6/, find the latest repo rpm, and install it as root:

`sudo rpm -Uvh http://elgis.argeo.org/repos/6/elgis-release-6-6_0.noarch.rpm`

Install Dependency Packages:

  1. yum install python-devel (needed by Shapely to compile C extensions)
  2. yum install bzip2 bzip2-devel (needed by Scrapy : remove this when this is no longer a dependency)
  3. yum install gdal gdal-devel
  4. yum install geos geos-devel
  5. yum install proj proj-devel
  6. yum install libxml2 libxml2-devel (needed to make xpath searching efficient)
  7. yum install libxslt libxslt-devel
  8. yum install sqlite sqlite-devel
  9. yum install expat expat-devel (this is needed by spatialite-tools)

Installing pythonz and virtualenv-burrito

TODO: Add instructions for doing this

Installing libspatialite, spatialite-tools and pysqlite

Why do this

  1. The default version of sqlite3 that is installed is not the current version (3.8.1 as of writing this), but an older version - 3.6.20 in my system. However, the current version of spatialite-tools will not compile with the older version. Hence, we have to compile/install this version. I did this from source (since my repos didn’t have the latest version).
  2. The default ‘make install’ installs all libraries/binaries on /usr/local/lib. This is usually not where the rpm packages install the libraries (in my system, this is /usr/lib64). When building, we have to make sure that the build system looks at this directory - something we will acheive using the export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig trick.

Installing Latest Version Of Sqlite (3.8.1)

First, let’s get the latest version of sqlite3 compiled and installed (to /usr/local/lib — so this shouldn’t mess with the yum installed version). For this, head over to http://www.sqlite.org/download.html and download the latest sqlite3-autoconf tarball. For me, that was http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz as of this time of writing.

  • Download to a directory using wget http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz or something similar.
  • Extract and cd to that directory
  • Do ./configure
  • Do sudo make install if you are not running as root (ignore ‘sudo’ if you are running as root).

Installing libspatialite

Installing ReadOSM

Installing spatialite-tools

Installing Pysqlite with enable_load_extension method available

Why do this

The default sqlite3 module or the external pysqlite modules don't come with the enable_load_extension method enabled (since some platforms have SQLite libraries which are compiled without this feature).

So, we have to compile the pysqlite3 extension with this feature enabled (since its easier to do this than to compile python)

Installing pysqlite