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

Richard Marsden winwaed at gmail.com
Fri Sep 27 14:08:20 PDT 2019


Further to my previous email (thanks Jukka!), I think I've found the
underling issue by using 'simple' Python (ie. no QGIS) on an ubuntu
box.

The problem lies with the interleaving and need to use multiple
passes. This larger issue is something I was already aware of having
coded a C# PBF reader in the past, and it is also in the docs.
This is the reason I had the loop over all layer types - even those I
didn't need. The issue was that the 'other relations' have to be read
BEFORE the multipolygons. As the missing features were "closed ways" I
didn't think the relations were relevant. Clearly they are.

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

Previously the loop was over  range (0,nly) - the same layers are
visited but previously they were in the order:
points,lines,linestrings,multipolygons,other relations.

Thanks

Richard



On Fri, Sep 27, 2019 at 11:13 AM Richard Marsden <winwaed at gmail.com> wrote:
>
> Jukka,
>
> Thanks - not sure how I missed that!  I've added that and I had a
> sudden increase in the number of reported nodes. Turned out my
> osmconf.ini had report_all_nodes=yes - and the default does not. So
> that turned out to be a good test that it was seeing the osmconf.ini
> that I thought it was. I've since disabled that option, however I'm
> still not seeing the polygons where osm_way_id has been set.
>
> I've also tried copying all polygons regardless of attribute values -
> the extra polygons are not there. "closed way" polygons aren't being
> reported, and I am not seeing any polygons with osm_way_id set to
> anything other than empty string.  The two specific tags examples I'm
> looking at are buildings and landuse.  My closed_ways_are_polygons= is
> set the same as the default:
>
> closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism,highway=platform,public_transport=platform
>
> [multipolygons] also has osm_id=yes set. The comments note that this
> automatically sets osm_way_id - the two attributes being exclusively
> set (which makes sense).
>
> Richard
>
>
>
>
> On Fri, Sep 27, 2019 at 12:53 AM jratike80
> <jukka.rahkonen at maanmittauslaitos.fi> wrote:
> >
> > Winwaed wrote
> > > Whilst searching this list, I saw references to osmconf.ini - turns
> > > out I have about half a dozen copies installed from various
> > > applications. They all have a "closed_ways_are_polygons" entry, which
> > > looks like it could be the cause of the problem.
> > > I tried copying one of these files to my plugin's directory, reloading
> > > the plugin, and no change.
> > >
> > > How can I programmatically check which osmconf.ini (if any) is being
> > > used, what the closed_ways_are_polygons= setting is set to? Is it
> > > possible to override it?
> >
> > Hi,
> >
> > Answer to how to define which osmconf.ini to use can be found from
> > https://gdal.org/drivers/vector/osm.html that says "You can also define an
> > alternate path with the OSM_CONFIG_FILE configuration option."
> >
> > -Jukka Rahkonen-
> >
> >
> >
> > --
> > Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list