My System (Ubuntu) previously had GDAL 1.11.2. We have an issue with using ogr2ogr converting KML to SHP in that the attributes were missing. In researching this, it seems that the LIBKML driver should fix this. I have tried researching various questions and tutorials on getting the LIBKML driver to work but I never seemed to get it working.

I have seen in other places that the LIBKML driver comes with GDAL in version 1.9.2 onwards. I got GDAL 2.1.3 on my system now, (verified with gdal-config --version), however when I run ogrinfo --formats, it is still only showing back KML and not both KML and LIBKML.

Is the LIBKML driver supposed to come with GDAL 2.1.3 out of the box?


As per request, here is the output from apt-cache policy gdal-bin

  Installed: 2.1.0+dfsg-1~trusty2
  Candidate: 2.1.0+dfsg-1~trusty2
  Version table:
*** 2.1.0+dfsg-1~trusty2 0
       100 /var/lib/dpkg/status
    1.10.1+dfsg-5ubuntu1 0
       500 http://mirror.rackspace.com/ubuntu/ trusty/universe amd64 Packages

Update with Solution I downloaded gdal in a weird way, as pointed out by @AndreJ Everytime I would uninstall everything, then reinstall the package, it still kept coming up with version 2.1.3 which isn't available through the PPA, which apparently doesn't have LIBKML.

What I had to do was manually locate gdal and locate kml and rm any and all files and instances found. After everything was gone, I could install gdal again and version 2.1.0 was installed with the LIBKML driver.

  • 1
    On Fedora it comes with KML driver: ogrinfo --formats | grep -i kml LIBKML -vector- (rw+v): Keyhole Markup Language (LIBKML) KML -vector- (rw+v): Keyhole Markup Language (KML) ... [neteler@oboe r.seasons]$ rpm -qf /usr/bin/ogrinfo gdal-2.1.2-5.fc25.x86_64 So it seems to depend on the packaging in the respective Linux distro.
    – markusN
    Feb 17 '17 at 22:27
  • Please include the result of apt-cache policy gdal-bin to your question to see from where you got GDAL.
    – AndreJ
    Feb 18 '17 at 7:56
  • @AndreJ check updated post
    – amallard
    Feb 18 '17 at 20:12
  • But that's GDAL 2.1.0, not 2.1.3?
    – AndreJ
    Feb 19 '17 at 7:11

It seems you have updated GDAL in an unusual way. GDAL 2.1.0 is available for trusty from the ubuntugis unstable ppa. After adding the ppa to your sources and updating gdal-bin, you should get the following output:

 $ ogrinfo --version
 GDAL 2.1.0, released 2016/04/25
 $ ogrinfo --formats | grep -i kml
 LIBKML -vector- (rw+v): Keyhole Markup Language (LIBKML)
 KML -vector- (rw+v): Keyhole Markup Language (KML)
 $ apt-cache policy gdal-bin
   Installiert:           2.1.0+dfsg-1~trusty2
   Installationskandidat: 2.1.0+dfsg-1~trusty2
  *** 2.1.0+dfsg-1~trusty2 0
         500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu/ trusty/main amd64 Packages
         100 /var/lib/dpkg/status
      1.10.1+dfsg-5ubuntu1 0
         500 http://ftp.halifax.rwth-aachen.de/ubuntu/ trusty/universe amd64 Packages

which clearly states LIBKML support for this GDAL package.

Update from comments

You have tried compiling GDAL 2.1.3 from source. This installs binaries in local folders where they can not be removed by dpkg or apt.

Instead, you have to carefully inspect the installation steps to see where the files are copied to, or which folders are included in search paths like $LD_LIBRARY_PATH. Delete those self-compiled files, and make sure no gdal command can be found, before doing a clean install from packages.

  • Honestly I'm not too fluent in this so I was trying a bunch of different methods. One way I did use was the PPA, sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update followed by sudo apt-get install gdal-bin which was how I "thought" I got version 2.1.3. When I run ogrinfo --version it goes give me GDAL 2.1.3, released 2017/20/01 though. So I'm not sure where I went wrong or how to fix it.
    – amallard
    Feb 19 '17 at 14:44
  • The method you describe is how to add ubuntugis stable ppa, but that has also package gdal 2.1.0+dfsg-1~trusty2. You must have another version (maybe self-compiled or self-extracted) with version number 2.1.3, which is only available for Debian experimental according to tracker.debian.org/pkg/gdal. You better remove all GDAL, including that version, before reinstalling from ubuntugis.
    – AndreJ
    Feb 19 '17 at 14:59
  • I've tried to remove it, but the version number of 2.1.3 still shows up when I type gdal-config --version and ogrinfo --version. I may have to start a new thread on this in the Ubuntu.SE, but do you have any suggestions on how I should completely remove gdal? I have --purge remove everything with gdal and kml in the dpkg --get-selections and apt-get list and gdal still seems to be installed on my system.
    – amallard
    Feb 19 '17 at 18:03
  • If you have compiled anything from source, dpkg and apt will not catch and remove those libs. But go ahead on Ask Ubuntu about it. I always use packages only.
    – AndreJ
    Feb 19 '17 at 20:26
  • ogrinfo from packages is in /usr/bin/ogrinfo, while your self-compiled version is in /usr/local/bin/ogrinfo, and will not get deleted by any dpkg or apt command.
    – AndreJ
    Feb 20 '17 at 17:08

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.