0

I'm using Python 3 and gdal/ogr module to open/read .osm.pbf data files downloaded from OpenStreetMap. With the method presented in this thread, I could successfully parse open the file a week ago through the following code:

import gdal, ogr

gdal.SetConfigOption('OGR_INTERLEAVED_READING', 'YES')
osm_pbf = ogr.Open('file.osm.pbf')

However, it all happened suddenly that the same method won't work any more to the same .osm.pbf data file. When I try to run osm_pbf = ogr.Open('file.osm.pbf') now, it always returns None. As osm_pbf is always None, it's impossible to parse the data any further.

Does anyone know what's happening here? Your kind help would be greatly appreciated.

mikeqfu
  • 329
  • 2
  • 10
  • I'm unable to install the module right now, but I'd take a look at the code of the `ogr.Open` function and find out in which situation it returns `None`. Maybe you have moved the `file.osm.pbf` file by accident on your disk, so `ogr.Open` is unable to find it. – GeckStar Jun 03 '17 at 20:28
  • Thanks @GeckStar . the path to `file.osm.pbf` is correct. Look forward to your response! – mikeqfu Jun 03 '17 at 21:43
  • I took a look at the source, but it's beyond my knowledge. The doc of the `Open` method however states: "NULL on error or if the pass name is not supported by this driver, otherwise an handle to a GDALDataset.". `NULL` here might mean `None` in Python. That's all I found out. Sorry. – GeckStar Jun 04 '17 at 17:35
  • Thanks @GeckStar anyway for your effort. – mikeqfu Jun 04 '17 at 21:00
  • I'm facing the same problem, after trying to use gdal from a python wrapper: https://github.com/dezhin/pygdal – istewart Nov 17 '17 at 19:28

0 Answers0