I am currently trying to extract road networks from OpenStreetMap dumps downloaded on Geofabrik. I am using the following osmosis (version 0.45) command to extract roads:

osmosis \
--rbf input.osm.pbf \
--tf reject-relations \
--tf accept-ways highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link,secondary,secondary_link,tertiary,tertiary_link,unclassified,residential \
--tf reject-ways highway=construction \
--lp --wb output_roads.osm.pbf

This should return a file containing all car roads except service roads.

However, some (and sometimes a lot of) roads are missing. I have tried this command on 3 input files:

  • "Midi-Pyrénées" French region: the road network seems almost complete. The attribute table contains 72010 elements.
  • all of France: a lot of roads are missing. The attribute table contains only 65803 elements (less than a single region). All types of highways are impacted: primary to residential. There is no any obvious pattern for the missing roads.
  • all of Europe: almost all roads are missing. The attribute table contains 62092 elements (less than all of France...).

I guess there is some limitation I am not aware of, either on the osmosis command or on the output file. What am I doing wrong here?

This may be unrelated but I have tried using the --used-node option in order to reduce the size of the output files, but this always generates an error (org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to create object stream writing to temporary file null.). I have no idea why.

Update 29/08/2018: I also tried using osmfilter (input.o5m --keep="highway=" > output_roads.osm), with the same results. I tried osmosis and osmfilter both on Windows 7 and Debian 9.5 (both 64 bits).

  • So consider using `--tf accept-ways highway=* \`, in your example you don't take into account all the type of road.
    – obchardon
    Commented Aug 20, 2018 at 12:30
  • 1
    Are you running a recent version of osmosis? And do you have enough free space on disk?
    – AndreJ
    Commented Aug 20, 2018 at 13:38
  • 1
    Sounds ok. have you tried --rb?
    – AndreJ
    Commented Aug 20, 2018 at 18:03
  • 2
    your suggestion gives almost the sames results (65356 elements for France) : This caught my attention : 65356 is exactly a 16 bit limitation of value (2^16), like an Int16 max value. I guess that must be the limitation you are looking for. Maybe you can't get more than 2^16 max features.
    – gisnside
    Commented Aug 23, 2018 at 9:49
  • 3
    65356 is a red herring, 2^16 is 65536. Commented May 6, 2019 at 9:07

2 Answers 2


I would recommend you using the HOT site to download OSM data. You can download data for a specific location or even draw a boundary for an area. and download only the road.


  • 1
    I'm not sure if this answers the question of how to do this in osmosis, but if the answer is you can't do it in osmosis and can in HOT, then I think you need at least to show how to do comparable queries to those in the question with number of results returned.
    – nmtoken
    Commented Feb 16, 2020 at 14:36

Try including all roads, for example use:

osmosis \
--rbf input.osm.pbf \
--tf accept-ways highway=* --used-node \
--wb output_roads.osm.pbf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.