The tools and format described here are not used on OSM servers. See OsmChange for the format that is currently used.
If you have fixed the software, or concluded that this notice does not apply, remove it.
(note: largely copied from https://svn.openstreetmap.org/applications/utils/planetdiff/readme.txt)
Generates a file containing the differences between two planet.osm dumps. For other methods of representing changes between sets of OSM data see OSM XML.
The program supports .gz and .bz2 compressed files transparently. It also runs an internal version of UTF8sanitizer on the input data so that it can be used on a file downloaded from https://planet.openstreetmap.org without needing any other manipulation.
Note that the algorithm used relies on the strict ordering of data in the planet.osm file to operate correctly. Data produced by other OSM tools normally do not follow these rules and can not be manipulated using this program.
Diff file format
The diff format is an XML file containing OSM objects to delete and add. Objects which are modified have both a delete and add section. The format of each section is a copy of the OSM object from the planet.osm file.
<?xml version="1.0" encoding="UTF-8"?> <planetdiff version="0.1" generator="OpenStreetMap planetdiff" from="a.osm" to="b.osm"> <add> <node id="10310557" timestamp="2006-07-10 23:17:35" lat="51.7670078090236" lon="-0.471281873153888"> <tag k="created_by" v="JOSM"/> </node> </add> <add> <node id="13602100" timestamp="2006-08-16 00:02:13" lat="51.778541285096" lon="-0.448173637230418"/> </add> <delete> <node id="26983956" lat="51.77874880458334" lon="-0.450481106821043"> <tag k="created_by" v="JOSM"/> </node> </delete> <add> <node id="26983956" lat="51.77874880458334" lon="-0.450481106821043"> <tag k="created_by" v="JOSMXX"/> </node> </add> ... </planetdiff>
The data must be in the exact order it is to be applied to the planet dump. The format is really based the output of "diff -u" but applied to XML. It is not a general diffing program between two sets of data, for that see osmosis.
This example shows how the tool can be used to extract the differences between two planet.osm dumps. The errors below are from the UTF8sanitizer code and can be ignored.
$ planetdiff planet-070307.osm.bz2 planet-070321.osm.bz2 > delta2.xml $ bzip2 -c delta2.xml > delta2.xml.bz2 $ ls -l -rw-rw-r-- 1 jburgess jburgess 10732308 Apr 6 11:41 delta2.xml.bz2 -rw-rw-r-- 1 jburgess jburgess 147704026 Apr 6 03:50 delta2.xml -rw-rw-r-- 1 jburgess jburgess 186168637 Mar 7 20:21 planet-070307.osm.bz2 -rw-rw-r-- 1 jburgess jburgess 193761852 Mar 22 19:24 planet-070321.osm.bz2
The planet.osm file can be regenerated using planetpatch below. The compressed diff file is only 10MB which is a much smaller download than a whole new planet.osm dump.
The patch file generated by the planetdiff example above is used to regenerate the planet-070321.osm file:
$ time planetpatch planet-070307.osm.bz2 delta2.xml > regen.xml Processing: node(8420k) Processing: segment(8830k) Processing: way(370k)Error at line 72505269 Processing: way(380k)Error at line 72583739 Processing: way(430k) real 19m54.654s user 12m59.771s sys 3m35.929s
The output file, in this case 'regen.xml' should now be the same as an uncompressed and UTF8sanitized version of planet-070321.osm.bz2
To compile it on Ubuntu 9.10, just do the following:
sudo apt-get install subversion zlib1g-dev libbz2-dev libxml2-dev svn checkout https://svn.openstreetmap.org/applications/utils/planetdiff/ cd planetdiff make planetdiff
Here you can download precompiled binary for Ubuntu 9.10. Simply extract the archive and execute planetpatch as above.