<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I put an example OSM file here: <a href="https://s3.amazonaws.com/gdal-osm-data/lake_huron.osm">
https://s3.amazonaws.com/gdal-osm-data/lake_huron.osm</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve been looking at <a href="http://www.gdal.org/drv_osm.html">
http://www.gdal.org/drv_osm.html</a> and saw a few tips, like setting OGR_INTERLEAVED_READING to YES and using the example do/while loop. Here’s my Python translation:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">import gdal<o:p></o:p></p>
<p class="MsoNormal">import ogr<o:p></o:p></p>
<p class="MsoNormal">import geojson<o:p></o:p></p>
<p class="MsoNormal">gdal.SetConfigOption("OGR_INTERLEAVED_READING", "YES")<o:p></o:p></p>
<p class="MsoNormal">ds = ogr.Open("test_water.osm")<o:p></o:p></p>
<p class="MsoNormal">feats = []<o:p></o:p></p>
<p class="MsoNormal">nonempty = True<o:p></o:p></p>
<p class="MsoNormal">while nonempty:<o:p></o:p></p>
<p class="MsoNormal">    nonempty = False<o:p></o:p></p>
<p class="MsoNormal">    for i in range(0, ds.GetLayerCount()):<o:p></o:p></p>
<p class="MsoNormal">        layer = ds.GetLayerByIndex(i)<o:p></o:p></p>
<p class="MsoNormal">        feat = layer.GetNextFeature()<o:p></o:p></p>
<p class="MsoNormal">        while feat is not None:<o:p></o:p></p>
<p class="MsoNormal">            feats.append(feat)<o:p></o:p></p>
<p class="MsoNormal">            nonempty = True<o:p></o:p></p>
<p class="MsoNormal">            feat = layer.GetNextFeature()<o:p></o:p></p>
<p class="MsoNormal">with open("output.geojson", "w") as fobj:<o:p></o:p></p>
<p class="MsoNormal">    fc = geojson.FeatureCollection(features=[geojson.loads(feat.ExportToJson()) for feat in feats])<o:p></o:p></p>
<p class="MsoNormal">    geojson.dump(fc, fobj)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:
<a href="https://s3.amazonaws.com/gdal-osm-data/osmconf.ini">https://s3.amazonaws.com/gdal-osm-data/osmconf.ini</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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”.<o:p></o:p></p>
</div>
<br>
This electronic communication and any attachments may contain confidential and proprietary information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee responsible for delivering this communication to the intended recipient,
 or if you have received this communication in error, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this communication in error, and delete the copy you received.
<br>
<br>
DigitalGlobe reserves the right to monitor any electronic communication sent or received by its employees, agents or representatives.
</body>
</html>