Skip to content
Laurent Grégoire edited this page Feb 6, 2015 · 1 revision

It is sometimes necessary, in order to compare various street options, to modify OSM data. If those modifications do not correspond to existing reality (for example a planned new road or change in one-way traffic direction), they can't be applied to the master OSM database (ie "committed").

A solution to this is to edit the OSM data locally with an editor such as JOSM. The problem is that those editors can't edit too large areas such as a whole city or region, so you can edit only a small region at a time. To process the result you thus need to merge the original complete data to be used with your opt instance with your local modifications.

Solution 1 - merging OSM files using osmosis

The following procedure addresses this issue:

  1. Extract the area you want to modify using the osmosis tool, or download it directly in the editor (JOSM).
  2. Edit your planned modification (adding new elements, changing the tags of existing elements, or disabling elements you want to remove). Make sure you DO NOT commit your modifications to the master OSM repository!
  3. Save the modified region as OSM XML format (modif.osm)
  4. Convert the modified region to OSM PBF (binary) format, using osmconvert:

osmconvert modif.osm --out-pbf > modif.pbf

  1. Merge the modified zone with the original whole zone (zone.pbf) using osmosis:

osmosis --read-pbf file=zone.pbf --read-pbf file=modif.pbf --merge --write-pbf omitmetadata=true file=zone-modif.pbf

  1. Build your graph using the resulting zone-modif.pbf.

Solution 2 - Let otp read the original and modified osm files

TODO -- Currently OTP has not the capability of ordering OSM files to read, so this is not an advised method.

Follow the same steps as solution 1 up to step 3, then build the graph using the two files (original whole zone and modified restricted zones) in the following order:

  1. First the modified restricted zones,
  2. Second the whole original zone.

How to remove elements

Do not remove roads or tags if you want to remove an element, as during the merge the removed elements will be re-applied again from the original un-modified data. You can however workaround this by disabling an element or a tag by providing a no-op tag. For example to remove a road you can set it's highway tag to proposed or abandoned.

The documentation on this wiki is outdated and should not be used

unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs

Clone this wiki locally