This project has moved and is read-only. For the latest updates, please go here.

SpatiaLite provider

As of revision 63679 the SpatiaLite provider originally created by Bill Dollins and further developed by Kev is part of the SharpMap.Extensions project.

What is SpatiaLite anyway?

Advertised as a complete spatial DBMS in a nutshell, SpatiaLite is an extension to the popular SQLite database engine, developed and maintained by Alessandro Furieri.


In order to use the SpatiaLite provider for SharpMap you need to do the following:
  1. Get native SpatiaLite binaries from SpatiaLite download page. You need at least
    1. libspatialite-win-x86 ... .zip-File *)
    2. proj-win-x86 ... .zip, geos-win-x86 ... .zip, libiconv-win-x86 ... .zip *) **)
  2. Extract the native DLL files to one directory.

Setup your Project

  1. Reference SharpMap and SharpMap.Extensions Assembly to your project.
  2. If not already present, add app.config / web.config file to your project. Add the following settings to it. Be sure to change the value for SpatiaLitePath to the folder you chose above.
        <add key="SpatiaLitePath" value="D:\GIS\SpatiaLite\2.4.0"/>
        The following key is needed, since SpatiaLite v2.3.1 library was
        named 'libspatialite-1.dll' by accident whereas as v2.2, v2.3.0
        and v2.4RC are named 'libspatialite-2.dll.
        Perhaps there will even be a v3.x?
        <add key="SpatiaLiteNativeDll" value="libspatialite-2.dll"/>

Construction of the provider

The constructor of the SpatiaLite provider takes four arguments
Parameter Sample/Meaning
ConnectionString Sample: Data Source=<path to spatialite database file>;[Password=<super secret password>;] For more information on connection strings to SQLite database files see ConnectionStrings.
TableName Name of the spatially enabled table.
GeometryColumn Name of the column that holds the geometry information. It is necessary that the combination of TableName and GeometryColumn has a valid entry in the 'geometry_columns' table of the SpatiaLite database file, because from this information, the possible usage of a spatial index is set up.
ObjectIdColumn Name of the unique feature identifier.

Sample Code

See WinFormsSample project for usage example.

*) If you need x64 binaries you are -at the moment- on your own, since they are currently not provided.
**) For SpatiaLite 2.4 proj, geos and libiconv have been put together into a dependency-win-x86 zip-File.

Last edited Feb 26, 2010 at 9:09 AM by FObermaier, version 5