How do I link OGR with spatialite?

المشرف العام

Administrator
طاقم الإدارة
Problem & Evidence:
I'm trying to create a spatialite file with the code snippet below. However the outDataSource object gets assigned NoneType and all subsequent (unshown) code fails. I'm thinking the problem is with the spatialite installation for two reasons:

1) When I choose 'ESRI Shapefile' as the driver and leave out the options=['SPATIALITE=yes'] the outDataSource is created correctly and all subsequent codes works as anticipated.

2) When I leave the driver as 'SQLite' but take out the options=['SPATIALITE=yes'], the non-spatial sqlite tables are indeed created. So, any ideas on what I am missing or might have done incorrectly to establish the link between OGR and spatialite?

Environment:
I'm developing on Spyder 2.3.0rc, with Python 2.7.7 32bits, Qt 4.8.6,PyQt4 (API v2) 4.10.4 on Windows, as delivered by the Anaconda-2.0.1-Windows-x86executable. Additionally, the development comments at the end of the code describe the steps I took to install spatialite.

Code:

# standard modulesimport os# third party modulesfrom osgeo import ogr############################################################################### create a new spatialite output file##############################################################################outputGridfn = os.path.join(os.getcwd(), 'grid.sqlite')outDriver = ogr.GetDriverByName('SQLite')outDataSource = outDriver.CreateDataSource(outputGridfn, options=['SPATIALITE=yes'])############################################################################### Development notes############################################################################### SPATIALITE functionality requires the following work# Step 0: Download DLL's from# latuviitta.org/documents/Spatialite_4.0_test_with_jre_1.6.zip# Step 1: Unzip and copy the spatialite DLL into the Python DLL library# Recompile the sqlite3 DLL from the amalgamation as follows# Step 0: Add '#define SQLITE_ENABLE_RTREE' to the sqlite3.c file# Step 1: gcc -c sqlite3.c# Step 2: gcc -shared -o sqlite3.dll sqlite3.o# Step 3: Place the DLL in the python DLL library# Add libgeo-3-3-1.dll to python DLL library

أكثر...
 
أعلى