I have a problem with ogr2ogr and osm file.

I install from source (on Ubuntu 12.04.2 LTS) newest GDAL libary and OGR still can't read osm files.

gdal-config --version
ogr2ogr --version
GDAL 1.10.0, released 2013/04/24
Supported Formats:
  -> "ESRI Shapefile" (read/write)
  -> "MapInfo File" (read/write)
  -> "UK .NTF" (readonly)
  -> "SDTS" (readonly)
  -> "TIGER" (read/write)
  -> "S57" (read/write)
  -> "DGN" (read/write)
  -> "VRT" (readonly)
  -> "REC" (readonly)
  -> "Memory" (read/write)
  -> "BNA" (read/write)
  -> "CSV" (read/write)
  -> "GML" (read/write)
  -> "GPX" (read/write)
  -> "KML" (read/write)
  -> "GeoJSON" (read/write)
  -> "GMT" (read/write)
  -> "PostgreSQL" (read/write)
  -> "PCIDSK" (read/write)
  -> "XPlane" (readonly)
  -> "AVCBin" (readonly)
  -> "AVCE00" (readonly)
  -> "DXF" (read/write)
  -> "Geoconcept" (read/write)
  -> "GeoRSS" (read/write)
  -> "GPSTrackMaker" (read/write)
  -> "PGDump" (read/write)
  -> "GPSBabel" (read/write)
  -> "SUA" (readonly)
  -> "OpenAir" (readonly)
  -> "PDS" (readonly)
  -> "HTF" (readonly)
  -> "AeronavFAA" (readonly)
  -> "EDIGEO" (readonly)
  -> "SVG" (readonly)
  -> "Idrisi" (readonly)
  -> "ARCGEN" (readonly)
  -> "SEGUKOOA" (readonly)
  -> "SEGY" (readonly)
  -> "ODS" (read/write)
  -> "XLSX" (read/write)
  -> "PDF" (read/write)

When I try this:

ogrinfo UMP-PL-CCBySA_20130717.osm

and I get this:

Unable to open datasource `UMP-PL-CCBySA_20130717.osm' with the following drivers.
Supported Formats:
  -> "ESRI Shapefile" (read/write)

Anyone know what I do wrong?

# Start with a clean copy of the svn source code repo:
$ svn co http://svn.osgeo.org/gdal/trunk/gdal

$ cd gdal

# Run configure and check its output, which should say something like:
$ ./configure
  Expat support:             yes
  SQLite support:            yes

# If it doesn't, check config.log to locate the problem(s) 
# and consult ./configure --help on how to fix them

# Once you configured correctly, run
$ make

# Then check the supported formats with
$ ./apps/ogrinfo --formats 

# Eventually, you run
$ sudo make install
  • It's working. Only one thing I do diffrent now, before I get source from download.osgeo.org/gdal/1.10.0/gdal-1.10.0.tar.gz Thanks a lot. – user19291 Aug 2 '13 at 7:39
  • Hmm. For me, both options work. In any case: once you are already building from source, it is best to work with the code from the source code repo. I've been doing this for years now. – Hermann Aug 2 '13 at 13:36
  • Are you sure this still works? I fail first line with Could not read status line: connection was closed by server (http://svn.osgeo.org) – geotheory May 27 '14 at 15:52
  • Works for me:$ svn co http://svn.osgeo.org/gdal/trunk/gdal A gdal/m4 A gdal/m4/lib-link.m4 ... – Hermann May 28 '14 at 5:16

As mentioned already, you need to configure like this:

$ ./configure --with-spatialite=yes --with-sqlite3 (...)

If things work fine, you will end up with this line in the list of supported vector formats:

  -> "OSM" (readonly)
  • Do I need to uninstall this first? Effect of ./configure --with-spatialite=yes --with-sqlite3 is SQLite support: yes SpatiaLite support: yes but in results of ogrinfo --formats (of course after make and sudo make install) I dont have -> "OSM" (readonly) – user19291 Jul 31 '13 at 9:37
  • you should run make clean before running make; make install – dmci Jul 31 '13 at 10:09
  • it looks like I forgot to mention that you also need the configure option: --with-expat=yes – Hermann Jul 31 '13 at 15:07
  • Thanks but still doesn't work. Maybe you can tell me how to do this from beginning, so I can find where I make mistake. – user19291 Aug 1 '13 at 9:06
  • OK. I will provide some more instructions in a separate answer. – Hermann Aug 1 '13 at 11:07

According to the comments here: http://www.gdal.org/ogr/ogr_formats.html

"needs libsqlite3 (and libexpat for OSM XML)"

OSM isn't included by default.

  • Thanks but I have newest versions of packets libsqlite3-0 and libexpat1. – user19291 Jul 31 '13 at 9:37

Based on this comment, and some hours of my debugging my process, may I suggest that the Driver Error may be due to a corrupt source file.

ogr2ogr missing drivers

Please check with a sample source file with the desired format.

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.