[gdal-dev] OSM driver won't generate feature for relation

Tim Harris Tim.Harris at digitalglobe.com
Wed Jul 12 14:50:56 PDT 2017


I also forgot to mention that I see 1000 instances of this error... I'm not sure if it's related.

ERROR 1: String buffer too small

I tried setting CPL_DEBUG to "OSM" and didn't see obvious errors. The output looks like this:

OSM: OGR_INTERLEAVED_READING = 1
OSM: For layer points, new max size is 128
OSM: Ways processed : 10000
ERROR 1: String buffer too small
ERROR 1: String buffer too small
...
ERROR 1: String buffer too small
More than 1000 errors or warnings have been reported. No more will be reported from now.
OSM: For layer lines, new max size is 128
OSM: For layer lines, new max size is 320
OSM: For layer lines, new max size is 608
OSM: For layer lines, new max size is 1040
OSM: For layer lines, new max size is 1688
OSM: For layer lines, new max size is 2660
OSM: For layer lines, new max size is 4118
OSM: For layer lines, new max size is 6305
OSM: For layer lines, new max size is 9585
OSM: For layer lines, new max size is 14505
OSM: For layer other_relations, new max size is 128
OSM: Remaining standalone polygons
OSM: For layer multipolygons, new max size is 128
OSM: For layer multipolygons, new max size is 320
OSM: For layer multipolygons, new max size is 608
OSM: Switching to 'lines' as they are no more feature in 'points'
OSM: Switching to 'multipolygons' as they are no more feature in 'lines'
OSM: Switching to 'other_relations' as they are no more feature in 'multipolygons'


From: Tim Harris
Sent: Wednesday, July 12, 2017 3:31 PM
To: 'gdal-dev at lists.osgeo.org'
Subject: OSM driver won't generate feature for relation

I'm trying to extract water vectors from OSM using my own local Overpass API server and OGR. It works for the most part, but there are some water features missing in my output. One particularly large omission is Lake Huron.

I put an example OSM file here: https://s3.amazonaws.com/gdal-osm-data/lake_huron.osm

I can see a <relation> in the file that corresponds to Lake Huron, it's the last element near the end of the file, <relation id="1205151">. It's got 12797 <member> elements that reference the 12797 <way> elements in the file (I think).

I've been looking at http://www.gdal.org/drv_osm.html and saw a few tips, like setting OGR_INTERLEAVED_READING to YES and using the example do/while loop. Here's my Python translation:

import gdal
import ogr
import geojson
gdal.SetConfigOption("OGR_INTERLEAVED_READING", "YES")
ds = ogr.Open("test_water.osm")
feats = []
nonempty = True
while nonempty:
    nonempty = False
    for i in range(0, ds.GetLayerCount()):
        layer = ds.GetLayerByIndex(i)
        feat = layer.GetNextFeature()
        while feat is not None:
            feats.append(feat)
            nonempty = True
            feat = layer.GetNextFeature()
with open("output.geojson", "w") as fobj:
    fc = geojson.FeatureCollection(features=[geojson.loads(feat.ExportToJson()) for feat in feats])
    geojson.dump(fc, fobj)

When I load output.geojson into QGIS and look at the line strings and polygons, I don't see a multipolygon for Lake Huron. I do see the outline as a bunch of line strings, but no polygon. I get a similar result if I load the OSM file into QGIS directly... no lake polygon. Just a few random smaller polygons around the perimiter. It seems like OGR just isn't producing a feature for that last relation.

I've tried messing around with osmconf.ini, including using the one from the QGIS plugin "QuickOSM". My most recent version of that file is here: https://s3.amazonaws.com/gdal-osm-data/osmconf.ini

Is there some setting I'm missing in osmconf.ini that would result in a multipolygon for the lake? The relation is there and it has a "type" tag set to "multipolygon".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170712/61e4f55a/attachment-0001.html>


More information about the gdal-dev mailing list