-
Notifications
You must be signed in to change notification settings - Fork 1k
Merging OSM data
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.
The following procedure addresses this issue:
- Extract the area you want to modify using the
osmosis
tool, or download it directly in the editor (JOSM). - 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!
- Save the modified region as OSM XML format (
modif.osm
) - Convert the modified region to OSM PBF (binary) format, using
osmconvert
:
osmconvert modif.osm --out-pbf > modif.pbf
- Merge the modified zone with the original whole zone (
zone.pbf
) usingosmosis
:
osmosis --read-pbf file=zone.pbf --read-pbf file=modif.pbf --merge --write-pbf omitmetadata=true file=zone-modif.pbf
- Build your graph using the resulting
zone-modif.pbf
.
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:
- First the modified restricted zones,
- Second the whole original zone.
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
.
unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs