QGIS SQLite Integration – Adding and Mapping Non-Spatial Tables

qgisspatialitesqlite

I have an sqlite file from my Wigle Android app (wiglewifi.sqlite). It's not a spatial file, just tables with lat/lon and other data.

I can add spatialite layers just fine, but cannot seem to find a way of adding this table in the same way I'd add a delimited text layer – how to go about doing this?

Clarification: It's possible to add as a table (as per @Giovanni-Manghi's answer below), OR it's possible to export the table as a CSV and then add as a delimited text layer, but ideally I'd like a point layer based directly on the SQLite table (in the same way as in ArcGIS I would add a table then right-click and "Display XY data…")

Best Answer

I don't know if this is the answer you want, as it's not a point and click answer, but this is how I would do it probably.

In Spatialite, add a new geometry column. Assuming you want WGS84 (lat/lon)

AddGeometryColumn( yourTableName , geometryColumnName, 4326, 'POINT', 'XY')

Then create the geometry from WKT generated from the X/Y coordinates

update yourTableName set geometryColumnName = GeomFromText('POINT ('+latColumn=' '+lonColumn+')',4326)

Perhaps there is a way of wrapping this into a qgis / spatialite / spatialite-gui function, as I seem to use this fairly frequently, and it's easy to get the quote marks wrong.

EDIT -----

There is actually a more foolproof way I discovered recently - for the second statement use:

update yourTableName set geometryColumnName = MakePoint(XColumn,YColumn,EPSG projectioncode)
Related Question