[GIS] Remove unused nodes from OSM data files

openstreetmap

For some experiments on OSM data size, I am using osmfilter to remove ways and relations with certain tags from the planet dump. But AFAIK osmfilter does not remove the corresponding nodes. So I'm left with a huge number of nodes that are not used by anything, and that distort my data size results.

Is there a tool to remove unused nodes (those that have no tags and are not referenced by either a way or a relation) from OSM data files (e.g. .pbf or .osm.bz2 files)?

Best Answer

You could drop all the data (--drop-*) and keep only the bits you're interested in (--keep-*)

Cfr http://wiki.openstreetmap.org/wiki/Osmfilter#Drop_all_Nodes.2C_Ways_or_Relations

You can also try with osmosis http://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage