GDAL – Fixing OGR2OGR Without Spatialite Support on Ubuntu Linux

gdallinuxogr2ogrspatialiteUbuntu

I am trying to use ogr2ogr to convert OSM data from pbf to spatialite. I used to do so with the following command:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES png-full-last.db planet_137.084,-15.689_157.615,1.255.osm.pbf

I am using Ubuntu Trusty 14.04. Recently I did an attempt to update GDAL to 2.0.1, which did not worked out. Later I attempted to completely remove GDAL using Synaptic. For this I removed also gqis, python bindings, gdal-bin, python-gdal, libgdal-dev and libgdal1h. Later I removed, clean and re-added all repositories. For some reason even when everything is removed, ogr2ogr is still available in the terminal (and I could not find a way to remove it).

Later I tried to re-install qgis with apt-get. I still get the same result, which is the following:

ERROR 6: OGR was built without libspatialite support
... sorry, creating/writing any SpatiaLite DB is unsupported

Can anyone orient me on how to fix ogr2ogr so it has again spatialite support?

Best Answer

I'd just like to add that checking for Spatialite support via
ogrinfo --formats sqlite | grep 'spatialite' -i
and an output of SQLite -vector- (rw+v): SQLite / Spatialite does not guarantee support. Mine outputs this but then ogr2ogr still fails claiming it does not support Spatialite.
Instead, use
ogrinfo --format sqlite | grep 'spatialite' -i (note the singular "--format")
to search within SQLite's options for Spatialite support. If it's truly supported, grep should give you more than Long Name: SQLite / Spatialite.

I hope this helps others that come along this post.