To update my database I need to extract some data from the OSM database. To do it I have downloaded the osm *.pbf file from the website of GEOFABRIK. From this PBF file I wish to extract all the polygons and multipolygons with some key values.

My problem is whatever command line I use with osmosis it seems that I miss the objects with the type multipolygon.

To illustrate my problem you will find the command I use for the object with the tag townhall in the keyword amenity.

To do that I have tried some command:

osmosis --read-xml nord-pas-de-calais-latest.osm --way-key-value keyValueList="amenity.townhall" --bounding-box top=50.794448377057 left=2.78824307841151 bottom=50.4995835747462 right=3.2719212468744 --used-node  --write-xml #target_file.osm#


osmosis --read-pbf nord-pas-de-calais-latest.osm.pbf --log-progress --tf accept-ways amenity=townhall --bounding-box top=50.794448377057 left=2.78824307841151 bottom=50.4995835747462 right=3.2719212468744 --used-node --write-xml extraction_test_townhall.osm

AND these commands lines

# read all nodes with amenity=townhall or townhall=yes, ignore ways and relations
osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-nodes amenity=townhall --tf reject-ways --tf reject-relations --write-xml amenity_townhall_nodes.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-nodes townhall=yes     --tf reject-ways --tf reject-relations --write-xml townhall_yes_nodes.osm

# read all ways with amenity=townhall or townhall=yes, keep only related nodes, ignore relations
osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-ways  amenity=townhall --used-node --tf reject-relations --write-xml amenity_townhall_ways.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-ways  townhall=yes     --used-node --tf reject-relations --write-xml townhall_yes_ways.osm

# read all relations with amenity=townhall or townhall=yes, keep only related ways and nodes
osmosis --read-xml nord-pas-de-calais-latest.osm
--tf accept-relations amenity=townhall --used-way --tf accept-relations townhall=yes --used-node --write-xml amenity_townhall_relations.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-relations townhall=yes --used-way --tf accept-relations townhall=yes --used-node --write-xml townhall_yes_relations.osm

# merge all files together
osmosis --rx amenity_townhall_nodes.osm --rx townhall_yes_nodes.osm --rx amenity_townhall_ways.osm --rx C:\Users\rjault\Documents\02_DEMANDE\13_OSM_ORACLE\OSMOSIS\townhall_yes_ways.osm --rx amenity_townhall_relations.osm --rx townhall_yes_relations.osm --merge --merge --merge --merge --merge --wx townhall.osm

It doesn't matter which command I use the result is always the same. You can see on the picture, In green the original dataset and in purple the townhalls I have extracted. The object surrounded in red for exemple is missing in my extraction.

enter image description here

I have also tried the solution brought by AKX but even there, I still miss the biggest townhall of my area. OSM seems to be a really nice database I wish to use it more.

  • Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. You appear to have created two accounts which inevitably leads to a frustrating experience for you, potential answerers and reviewers so please follow these instructions ASAP to merge your accounts.
    – PolyGeo
    Sep 25 '21 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.