8

I'm having a problem with "flooded" islands when converting OSM natural=water data to shapefiles and opening it in qgis. It doesn't happen consistently; as you can see from the attached screenshot, some islands are fine, but others initially show up, then get covered by the parent water polygon.

Here's how I'm generating my data:

osmconvert north-america-latest.osm.pbf -b=-80,40,-70,50 --complete-ways --complex-ways -o=w080n40.o5m
osmfilter w080n40.o5m --keep= --keep-ways="natural=water" --keep-relations="natural=water" -o=water.osm
ogr2ogr -skipfailures -f 'ESRI Shapefile' water water.osm

Then I open the resulting polygon layer in qgis, with the result illustrated.

Illustration of "flooded" islands in qgis

5
  • 1
    If you only keep ways and relations with natural=water, you might miss islands of different landuse that are inner rings in water multipolygons.
    – AndreJ
    Commented Dec 23, 2016 at 15:36
  • Thanks, Andrej. I'll try that and see if it helps. I was thinking in terms of holes in traditional layers.
    – Canuck
    Commented Dec 23, 2016 at 15:55
  • 1
    Yes, that solved it—thanks! Still getting my head into the OSM mindset. If you'd like to repost that as an answer, @AndreJ, I'll accept it.
    – Canuck
    Commented Dec 23, 2016 at 16:01
  • 1
    If you solved it, you can answer your own question with the command line that worked for you.
    – AndreJ
    Commented Dec 23, 2016 at 18:10
  • No problem, Andre. I was hoping to give you credit, but if that's not a big deal, I'll copy the answer there.
    – Canuck
    Commented Dec 23, 2016 at 22:18

1 Answer 1

7

Thanks to @AndreJ for the final answer. It turns out that it's a bad idea to try to filter by attribute value using osmfilter; instead, just filter by attribute key, then do the per-value filtering in qgis. That way, relations and ways stay together. Example:

osmfilter w080n40.o5m --keep= --keep-nodes="natural=" --keep-ways="natural=" --keep-relations="natural=" -o=natural.osm

Then add qgis filter to the layer with natural='water'

2
  • Hi Canuck - You may want to accept your own answer so that others can see that your question has been resolved.
    – Cyrus
    Commented Dec 24, 2016 at 0:55
  • Thanks, @Cyrus . Unfortunately, the site makes me wait 2 days before accepting my own answer, but I will do it tomorrow when the cooling-off period expires.
    – Canuck
    Commented Dec 24, 2016 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.