Osmium tags-filter -i left orphan nodes

Hi, when I try to filter out buildings (e.g.: nord-ovest-latest.osm.pbf -i wr/building -o nw-no_building.osm.pbf OR nord-ovest-latest.osm.pbf -i building -o nw-no_building.osm.pbf) I get all the orphan nodes from the deleted geometries. Is there an option or any other command in osmium to get rid of those nodes?
Thank you

There is no easy way to do this, unfortunately. The problem is that those nodes could be referenced from something else in addition to been referenced from the buildings you deleted. You could use osmium cat -t way -t relation -o wr-only.osm.pbf to get a file that contains only ways and relations, then use osmium getid -r -I wr-only.osm.pbf to create a file that only contains ways and relations and all nodes referenced by them. You are still missing all tagged nodes, though. You can get them with osmium tags-filter input.osm.pbf "n/*". Then you can use osmium merge to bring everything together.

I haven’t tried this, so you might need to experiment a bit, but that should give you some ideas what could work.

Uh thank you Jochen (and kudos for the amazing software you develop).

It’s definitely not straightforward, but perhaps: getting the building ID before deleting and run getid to get nodes (probably recursively if building is a relation), after that on each node: first check it doesn’t have tag, second run getparents to check if the node is not shared on other (not) building geometry; if so you can delete it.

Maybe it could works on small extracts, going regional would be already too much :-)