This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

How to edit a local pbf and update the source

0

Hello all,

I have a local OSRM server where I do some traffic simulations for studies, and I need to change some maxspeeds on the map.

What I am trying to do:

  • Download a pbf from geofrabrik
  • use osmosis to cut a small chunk where I want to edit. -
  • edit the chunk with JOSM And now I am stucked on how I merge the edits with the original pbf. I tried use osmosis to calculate diff, but if I use:

    osmosis --read-xml file="sudeste-latest-osm_02.osm" --read-pbf file="sudeste-latest.osm.pbf" --derive-change --write-xml-change file="changeset.osc"

When I apply the diffs to the original "sudeste-latest" with:

osmosis --read-xml-change file="changeset.osc" --read-pbf file="sudeste-latest.osm.pbf" --apply-change --write-pbf file="sudeste-new.osm.pbf"

The output file contains only the chunk that I updated.

If I calculated the diffs with:

osmosis --read-pbf file="sudeste-latest.osm.pbf" --read-xml file="sudeste-latest-osm_02.osm" --derive-change --write-xml-change file="changeset.osc"

When I apply the osc, none of my changes was applied. What I'm doing wrong?

Thank you!

asked 27 Apr '21, 19:52

rafaelricco's gravatar image

rafaelricco
11111
accept rate: 0%

edited 27 Apr '21, 19:54


One Answer:

1

Osmosis doesn't understand the JOSM xml file.

Osmium might work (I'm not sure): https://docs.osmcode.org/osmium/latest/osmium-apply-changes.html

If you create objects, you might also have to synthesize positive ids for them to satisfy the OSRM importer (I don't know if it supports negative ids or not).

answered 28 Apr '21, 03:08

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Nice! I will give a try using Osmium!

Apparently, if instead of derive changes from the bigger pbf, I use the edited chunk against the non-edited chunk:

osmosis --read-xml file="sudeste-latest-osm_02_new.osm" --read-pbf file="sudeste-latest-osm_02_old.osm" --derive-change --write-xml-change file="changeset.osc"

Them the changeset was applied to the original pbf, but Osmium seems to me to be more cleaner, let see!

Thank you!

(28 Apr '21, 18:18) rafaelricco