5

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?

3
  • 1
    Its very difficult to say unless you can tell us which repositories you used at which stages, how you tried to update GDAL, and where ogr2ogr is coming from. What does which ogr2ogr on the command line show you?
    – BradHards
    Commented Nov 3, 2015 at 6:39
  • It says: /usr/local/bin/ogr2ogr How can I start from scratch in that case? I don't mind doing a complete uninstall, but I can't figure out how to do so... Commented Nov 3, 2015 at 7:27
  • I'd just manually uninstall (i.e. rm) the relevant files and directories in /usr/local/bin and /usr/local/lib. It doesn't sound like you are confident with rebuilding software, but a rebuild of gdal with the spatialite options turned on would also be an option.
    – BradHards
    Commented Nov 3, 2015 at 10:28

3 Answers 3

4

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.

3

Finally the solution was a combination of these two posts:

Thanks to all for the feedback provided!

2
  • Try this first: export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
    – vinh
    Commented Mar 29, 2018 at 8:22
  • Can you share your full steps on this in addition to links? Commented Nov 30, 2018 at 21:05
1

You will probably need to build GDAL from source; you can download the tar ball here.

Before compiling, ensure that you have installed the Spatialite libraries (& you could also install the binaries at the same time):

apt-get install libspatialite-dev libspatialite5 spatialite-bin

Then run the following to build GDAL/OGR with spatialite support:

./configure --with-spatialite 
make
sudo make install

When it has completed, you can check that ogr supports spatialite as follows:

ogrinfo --formats | grep 'Spatialite'

SQLite -vector- (rw+v): SQLite / Spatialite
5
  • thanks for the reply. Do I need to uninstall previous versions? Or they will be overwritten by the process? Will QGIS be affected by the new build? Commented Nov 3, 2015 at 11:59
  • I have compiled the latest Gdal as described above (2.0.1). Everything worked out well during compilation. When trying ogrinfo I get the following answer: ogrinfo --formats | grep 'Spatialite' ogrinfo: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory Something must have gone missing in the way... Your feedback is appreciated. Thanks! Commented Nov 3, 2015 at 23:21
  • An extra comment: I have tried the solution pointed here: [gis.stackexchange.com/questions/157406/…, but I still get the same error, plus an additional of "no version information available". Here is the full output ogr2ogr: /usr/local/lib/libgdal.so.1: no version information available (required by ogr2ogr) ERROR 6: OGR was built without libspatialite support ... sorry, creating/writing any SpatiaLite DB is unsupported SQLite driver failed to create png-full-last.db Commented Nov 4, 2015 at 0:29
  • have you run: ldconfig after the installation?
    – dmci
    Commented Nov 4, 2015 at 10:26
  • --with-spatialite was what I needed
    – maxbellec
    Commented Feb 19, 2019 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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