Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a project open in QGIS and am trying to import an Ordnance Survey Address Point layer into SpatiaLite. I have recently installed the Qspatialite plugin. I open SpatiaLite in the DB Manager then use the Import QGIS layer to choose the Address Point layer. I then get the following Python error code data and have no idea of what is happening.

An error has occured while executing Python code:

Traceback (most recent call last): File "/Users/Nlaw/.qgis//python/plugins/QspatiaLite/importQgis/importQgis.py", line 64, in run if not self.parent.db.uploadQgisVectorLayer(layer, tableName=self.tablenames[i], srid=self.srid, selected=self.selected): File "/Users/Nlaw/.qgis//python/plugins/QspatiaLite/Classes/Database.py", line 249, in uploadQgisVectorLayer header,data=self.executeQuery("""INSERT INTO "%s" VALUES (%s,%s)"""%(tableName,','.join([unicode(value).encode('utf-8') for value in values_auto]),','.join('?'*len(values_perso))),tuple([unicode(value) for value in values_perso]),commit=True) File "/Users/Nlaw/.qgis//python/plugins/QspatiaLite/Classes/Database.py", line 45, in executeQuery cursor.execute(query,params) IntegrityError: AddressPoint.Geometry violates Geometry constraint [geom-type or SRID not allowed]

Python version: 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

QGIS version: 1.8.0-Lisboa Lisboa,

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/Nlaw/.qgis//python', '/Users/Nlaw/.qgis//python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/3/Python/2.7', '/Library/Frameworks/GDAL.framework/Versions/1.9/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools', '/Users/Nlaw']

share|improve this question
    
Could a Mod please remove my answer below as this problem still exists and the answer is plain wrong:( –  Nigel Law Jan 13 '13 at 17:06
    
The relevant part is "AddressPoint.Geometry violates Geometry constraint [geom-type or SRID not allowed]". What is the type of the addresspoint geometry (e.g. probably a Point?). What is the input spatial reference system (4386 == WGS-84, a UTM zone, or some regional system?). What did you specify for your database setup? –  BradHards Jan 13 '13 at 20:56
    
@BradHards. This is some of the contents of the layer Metadata. /Users/Nlaw/mapping/destination/AddressPoint.shp Geometry type of the features in this layer: Point Extents: In layer spatial reference system units : xMin,yMin 639573.10,309485.10 : xMax,yMax 640873.00,311053.30 Layer Spatial Reference System: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0 +units=m +no_defs Does this help as I don't fully understand everything in your comment. I did no specify anything in the database setup I just imported the layer. –  Nigel Law Jan 13 '13 at 21:12

1 Answer 1

up vote 1 down vote accepted

Spatialite expects data coming with SRS as defined by EPSG-codes. If you only have a proj string, you have to define a user SRS in Qgis. But that can not easily be exported to Spatialite.

Your data should be in EPSG:27700. Spatialite works with this definition:

+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs

with +datum=OSGB1936 expanding to a 7-parameter +towgs84 value.

Your data (and QGIS) has the three-parameter value, which is less accurate. That's why spatialite thinks its not the same, and refuses the import.

You could try the spatialite GUI to import the data into the database.

share|improve this answer
    
Thanks for that Andre. Changing the layer CRS before I imported it got rid of the import error. –  Nigel Law Jan 14 '13 at 14:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.