osmcode / osmium-tool

Command line tool for working with OpenStreetMap data based on the Osmium library.
https://osmcode.org/osmium-tool/
GNU General Public License v3.0
509 stars 107 forks source link

Remove unused nodes from OSM data files #251

Closed RakeshGupta-TomTom closed 1 year ago

RakeshGupta-TomTom commented 2 years ago

osmium version 1.11.1 libosmium version 2.15.4

I have removed ways and relation based on my tag filtering logic , but reference nodes which are either direct member of relation or ways created using nodes could not removed . now I want to remove only those nodes for which I have removed relation and ways only not other existing nodes . is there any way to do so ?

joto commented 2 years ago

I am not sure I understand exactly what you are trying to do, but have a look at osmium getid -r. You'll probably also need to keep all tagged nodes, you can find them with osmium cat -f opl -t n | grep -v ' T '.

RakeshGupta-TomTom commented 2 years ago

thanks for the quick response , let me explain you the scenario what I have I have one pbf file , i wrote one program to remove ways and relation based on some xyz tag information and within provided bounding box now I am able to remove ways and relation but nodes used inside ways and some nodes are only member of relation eg. admin_center . now want to remove nodes as well as which are member of relation and ways created using nodes

joto commented 1 year ago

If I understand correctly you want to remove all nodes which don't have tags and are not referenced by any ways or relations in a file, making them essentially useless.

There is currently no way to do that directly, but you can build something with some scripting using the ideas I mentioned above.

I could imaging that functionality like that could be useful in some scenarios, but it is somewhat specific, so I would only add that if there is some funding for it. Closing here.