[gdal-dev] Importing OSM: closed ways being skipped
Richard Marsden
winwaed at gmail.com
Fri Sep 27 14:58:08 PDT 2019
Even,
Thanks - I'll have a look at ds.GetNextFeature(). I'll note that the
sample (C++) code on the interleaved reading section, is where I got
the double loop that looped over layers, and then features within that
layer. This led me astray because it loops over the layers in index
order - doing this results in the closed ways being skipped.
Richard
On Fri, Sep 27, 2019 at 4:28 PM Even Rouault <even.rouault at spatialys.com> wrote:
>
> > 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
> https://gdal.org/drivers/vector/osm.html#interleaved-reading
>
> 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
> http://www.spatialys.com
More information about the gdal-dev
mailing list