[gdal-dev] Importing OSM: closed ways being skipped

Even Rouault even.rouault at spatialys.com
Fri Sep 27 14:28:53 PDT 2019

> The amended code looks like this:
>         ds = gdal.OpenEx(input_pbfname, gdal.OF_VECTOR)
>         nly = ds.GetLayerCount()
>         ds.ResetReading()
>         for ily in (0,1,2,4,3):
>             layer = ds.GetLayerByIndex(ily)
>             layer.ResetReading()
>             feat = layer.GetNextFeature()
>             while feat is not None:
>                  # do stuff with feat

This is not the proper way of doing layer interleaved reading. It might work 
by chance on your particular dataset, but not in the general case. See

With recent GDAL versions, you might also use ds.GetNextFeature()

See https://github.com/OSGeo/gdal/blob/master/autotest/ogr/ogr_osm.py#L702

Spatialys - Geospatial professional services

More information about the gdal-dev mailing list