0

I am trying to export some spatial data from SQL Server 2012 to Spatialite with the following command

ogr2ogr  -f SQLite -update C:\tmp\Spatial.sqlite -nln "my_polygons" "MSSQL:server=host;database=MySQLDB;trusted_connection=yes;GeometryFormat=native;" -sql "SELECT *  FROM MySQLDB.dbo.my_polygons"  -lco SPATIAL_INDEX=yes -gt 65536

Ogr2ogr does write from SQL Server to my Spatialite db however the imported table is not recognised as a spatial table.

When trying to view the result in QGIS is doesn't show any polygons. However I can see the table and the attributes!

Spatial data from SQL Server not recognised in Spatialite

1

If anyone has the same issue, here is the workaround.

I found out that the geometry_type and srid weren't blank in the spatialite geometry_column.

After updating the table I got the layer coming up nicely in QGIS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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