Show/Hide Toolbars

Ultra Mileage

Navigation: Miscellaneous

Creating a Custom PBF File

Scroll Prev Top Next More

You are not limited to using our PBF files. The Ultra Pre-Processor can work with any OpenStreetMap PBF file that contains road data. You may wish to work with your own custom area if you need to keep the data small, or if you wish to calculate routes that cross boundaries which are not supported by our road packs.


Download servers for the complete Earth ("planet") data and various area extracts are listed on the OpenStreetMap Wiki's Planet.osm page. You should download the PBF file and not the bzip2 file. Note that the full planet file is approximately 40GB in size.


It is possible that one of these servers has an area extract that meets your needs. If so, you can immediately use the downloaded PBF file with the Ultra Pre-Processor. If not, you will need to extract your required data area. You can extract this data online using the Overpass API, but for larger file extracts we recommend you download a larger file and extract the required data locally. This also allows you to create multiple extracts from the one downloaded file, without the need for multiple large downloads.


For local PBF processing activities including area extraction, we recommend the use of the osmosis command line tool. Download and installation instructions plus a tutorial can be found on the OpenStreetMap Osmosis page.


Usually we extract the road data from the input PBF data before progressing any further. This results in a smaller disk file and helps make Ultra Pre-Processor's input routines more efficient. This is how we do this with Osmosis:


osmosis --read-pbf-fast workers=4 file=planet.pbf

       --tf accept-ways highway=* --used-node

       --write-pbf omitmetadata=true file=roadfile.pbf


This line takes planet.pbf as input and creates a new file called roadfile.pbf. As well as only extracting the road data, this command filters out all of the unnecessary meta data. This includes things like data and author details which are not used by the Ultra Pre-Processor. Note: This particular example does not retain any ferry data. The most efficient number of worker threads will vary according to your PC, but we have found 4 to be a good value on a 6 cpu (12 core) machine with a conventional hard disk.


A rectangular area can be extracted by using the bounding-box parameter:


osmosis --read-pbf file=input-file.pbf

      --bounding-box top=49.5138 left=10.9351

                      bottom=49.3866 right=11.201

       --write-pbf file=region.pbf


More complex polygons can be extracted by using the bp parameter:


osmosis --read-pbf file=input-file.pbf

       --bp file=region.poly

       --write-pbf file=region.pbf


region.poly is a text file that specifies the polygon area(s) that should be extracted. See below for format information.


Processing of large files can take a long time. If you need to extract multiple areas at the same time, it is more efficient to use the tee command:


osmosis --read-pbf file=input-file.pbf

       --tee 2

       --bp file=region_a.poly --write-pbf file=region_a.pbf

       --bp file=region_b.poly --write-pbf file=region_b.pbf


This extracts two regions (a and b) simultaneously, and is more efficient than running osmosis twice.


The OpenStreetMap wiki also contains a detailed description of Osmosis usage.  An alternative to osmosis is osmconvert. This is simpler but it can only process one file at a time. Details can be found on the OpenStreetMap Osmconvert page.