Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting GeoDjango + Spatialite running on Windows

I continue to have problems setting up a GeoDjango installation that uses Spatialite as a backend on a Windows machine.

I used the GeoDjango installer and downloaded the precompiled libraries from http://www.gaia-gis.it/spatialite/binaries.html, and dumped them into my geodjango/bin directory.

I upgraded my pysqlite2 installation to the newest version, so that extensions can be loaded and I specified SPATIALITE_LIBRARY_PATH in my settings file.

When I run manage syncdb I get the following output

C:\stuff>manage.py syncdb
SpatiaLite version ..: 2.3.1    Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork       [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.0.2-CAPI-1.4.2

However, when setting up the indices for the table I get the following message:

...
Installing custom SQL for core.LocationHint model
updateTableTriggers: "no such module: rtree"
...

I tried to ignore the message, however my models would not save correctly.

I am a little baffled, because the Spatialite library seems to be used and has the "RTree" extension enabled, yet I still get the error message. There is not much information about this error available online; I found the RTree Documentation at sqlite.org/rtree.html, however I was under the impression that it is already included in spatialite because it is listet under "supported extensions".

Do I really need to compile my own sqlite library? Can somebody provide a .dll that already has RTree included? Am I doing something completely wrong? Any help is appreciated, thanks!

like image 812
Hans Avatar asked Nov 25 '09 23:11

Hans


People also ask

How do I install GeoDjango?

First, download the OSGeo4W installer (64bit), and run it. Select Express Web-GIS Install and click next. In the 'Select Packages' list, ensure that GDAL is selected; MapServer is also enabled by default, but is not required by GeoDjango and may be unchecked safely.


1 Answers

Hans, spatialite is an extension to SQLITE3.

SQLite3 needs to be specifically compiled with this option, and it is often not. For example the default version on mac does is not compiled with RTREE. However i think sqlite3 should be included though your python installation & pysqlite maybe using the original version of sqlite3 or another version.

you can try, sqlite3.version to see which version is being used by python.

Also note, you have to re-install pysqlite module with the correct config options i.e before running setup.py install, change the setup.cfg:

[build_ext]
#define=
include_dirs=PATH_TO_INCLUDE
library_dirs=PATH_TO_LIBS
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

http://www.gaia-gis.it/spatialite/install-windows.html

like image 59
ismail Avatar answered Oct 14 '22 20:10

ismail