This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Filter rivers with Osmosis

0

I'm trying to filter rivers, highways and water from a planet file in Osmosis as follows:

osmosis \
--read-pbf-fast file="planet-latest.osm.pbf" workers=8 \
--buffer \
--tf accept-relations natural=water waterway=riverbank highway=*  \
--used-way \
--used-node \
--write-pbf planet-RELATIONS.osm.pbf

osmosis \
--read-pbf-fast file="planet-latest.osm.pbf" workers=8 \
--buffer \
--tf accept-ways natural=water waterway=riverbank highway=* \
--tf reject-relations \
--used-node \
--write-pbf planet-WAYS.osm.pbf

#MERGE RELATIONS AND WAYS
osmosis \
--read-pbf-fast file="planet-RELATIONS" workers=8 \
--read-pbf-fast file="planet-WAYS" workers=8 \
--merge \
--write-pbf planet-MERGED-highway-water-riverbank.osm.pbf

After that I turn the .pbf into GeoJSON with Ogr2ogr and then into .mbtiles with Tippecanoe. The highways and water work perfectly, but the rivers are messy: parts of every river works well while some parts have broken polygons, and others parts are shown as multilinestrings even though they should(?) be polygons.

If you have any pointers on how to filter rivers properly I'd greatly appreciate it! (If this is the wrong forum for this question please redirect me!)

asked 29 Jul '17, 21:11

Azei's gravatar image

Azei
15113
accept rate: 0%


One Answer:

5

Not sure what osmosis and ogr2ogr are doing exactly, try with osmium:

osmium tags-filter planet-latest.osm.pbf natural=water waterway=riverbank highway \
    -o planet-highway-water-riverbank.osm.pbf

Much easier command line and much faster than osmosis.

There is also an osmium export command that can convert this into GeoJSON, but it is not in the released version yet and only available in the export branch on github.

answered 29 Jul '17, 21:32

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

2

It turns out ogr2ogr was the problem, converting waterway=river to lines when doing the .pbf to .geojson conversion when really they should be converted to polygons. With osmium export I got that working, thanks alot!

Also for the record, osmium tags-filter turns out to be orders of magnitude faster and simpler than osmosis for anyone interested.

(30 Jul '17, 12:24) Azei

Source code available on GitHub .