1

to update my database I need to extract some datas from 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 probleme 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#

OR

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 those 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.

So thank you for your help.

NcXNaV
  • 1,657
  • 4
  • 14
  • 23
ROME
  • 11
  • 1

1 Answers1

0

This helped but it keeps a selected set of points which contain both road and building data.

osmosis --rx file="input file" --tf accept-ways building=* geometry-type=multipolygon --wx "output file"
  • Hello, I just saw you advice. Thank you a lot for it. I will have a look to it and I will keep you in touch very soon. – ROME Sep 22 '21 at 13:48
  • hello Madara, I have tried your solution, the element with the type multipolygon I am looking for are still not extracted. I keep looking for a solution. Thanks for your help. – ROME Sep 29 '21 at 09:52
  • Hi @ROME, If you can use QGIS or identify a specific key that describes the building (E.g. : Name) you can perhaps give it as an accept value. For an example if building was called "Peoples Bank Ohio" the query will be : osmosis --rx file="input file" --tf accept-ways building="Peoples Bank Ohio" geometry-type="multipolygon" --wx "output file" – Madara Premawardhana Sep 30 '21 at 08:13