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 Aug 20 '18 at 12:30
  • 1
    Are you running a recent version of osmosis? And do you have enough free space on disk? – AndreJ Aug 20 '18 at 13:38
  • 1
    Sounds ok. have you tried --rb? – AndreJ Aug 20 '18 at 18:03
  • 1
    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 Aug 23 '18 at 9:49
  • 2
    65356 is a red herring, 2^16 is 65536. – bugmenot123 May 6 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.