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. 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.

 

Osmosis POLY File Format

 

The POLY file format is used by Osmosis to specify the polygon area(s) to extract. The easiest way to create a POLY file is to use the JOSM OpenstreetMap Editor with the poly plugin. Geofabrik also publish POLY files for their data extracts.

 

The full description of the POLY format can be found on the OpenStreetMap Wiki's Polygon Filter File Format page. Here is an example of two polygon file (name: "australia_v") where the second polygon is a hole:

 

australia_v
1
     0.1446763E+03    -0.3825659E+02
     0.1446693E+03    -0.3826255E+02
     0.1446627E+03    -0.3825661E+02
     0.1446763E+03    -0.3824465E+02
     0.1446813E+03    -0.3824343E+02
     0.1446824E+03    -0.3824484E+02
     0.1446826E+03    -0.3825356E+02
     0.1446876E+03    -0.3825210E+02
     0.1446919E+03    -0.3824719E+02
     0.1447006E+03    -0.3824723E+02
     0.1447042E+03    -0.3825078E+02
     0.1446758E+03    -0.3826229E+02
     0.1446693E+03    -0.3826255E+02
END
!2
     0.1422483E+03    -0.3839481E+02
     0.1422436E+03    -0.3839315E+02
     0.1422496E+03    -0.3839070E+02
     0.1422543E+03    -0.3839025E+02
     0.1422574E+03    -0.3839155E+02
     0.1422467E+03    -0.3840065E+02
     0.1422433E+03    -0.3840048E+02
     0.1422420E+03    -0.3839857E+02
     0.1422436E+03    -0.3839315E+02
END
END