Osmchange (program)

From OpenStreetMap Wiki
Jump to navigation Jump to search

osmchange is a tool to merge .osc OsmChange files into an .osm Planet file. You can define a bounding box or a bounding polygon to get a limitation of the map region in the same process. This tool is written in C and rather fast.

For new projects please use osmconvert since osmchange does not support modern OSM file formats, such as pbf or o5m.

Download

These Downloads are available:

(As usual: There is no warranty, to the extent permitted by law.)

Program Description

There are two major functions: updating an .osm file and limiting an .osm file to a certain geographical region.

Updating .osm Files

If you have an .osm file, you can merge is with .osc OSM change files to update it. For example, you have a planet.osm file or a regional germany.osm file from yesterday, you can apply the daily change file from this morning to get an up-to-date planet.osm, resp. germany.osm file. The syntax is like this:

<old.osm ./osmchange changefile.osc >new.osm

In case your .osm file is older, you can apply two or more change files simultaneously:

<veryold.osm ./osmchange c1.osc c2.osc c3.osc >new.osm
<day24.osm ./osmchange c24_25.osc c25_26.osc >day26.osm

You also can handle compressed .osm files. For example:

bzcat a.osm.bz2 | ./osmchange changefile.osc | gzip -1 >b.osm.gz

Compressed .osc file(s) must have been decompressed before you are going to use them with osmchange.

Limitations: The OSM objects in the change file must be unique. That means, there has to be only one occurrence of every node, way or relation. Minutely or hourly change files may contain more than one version of OSM objects, therefore they cannot be merged with osmchange program. Please use the daily change files or try osmconvert with --merge-versions option.

Applying geographical borders

If you want to limit the geographical region of an .osm file, you can use a bounding box. To do this, enter the southwestern and the northeastern corners of the box. For example:

<germany.osm ./osmchange -b=10.5,49,11.5,50 >nuernberg.osm

Instead of a simple bounding box you can use a border polygon file. This will allow a more accurate limitation to a political border, for example.

<germany.osm ./osmchange -B=hamburg.poly >hamburg.osm

The format of a border polygon file can be found in the OSM Wiki: here. You do not need to follow strictly the format description, but you must ensure that every line of coordinates starts with blanks.

Combining the functions

The previously introduced functions can be combined. Thus you can update an .osm file and limit its region in one pass. For example:

<day24.osm ./osmchange -B=p.poly c24_25.osc >day25.osm

Plausibility Check

The parameter -t disables the standard output. This is useful if you want to check a file and do not need any output data. You will get error and warning messages only.

Input File

If your operating system provides only low performance pipes for standard input, you can use the -i parameter to read an uncompressed .osm file directly. This may be useful under Windows. For example:

./osmchange -i=old.osm changefile.osc >new.osm

Usage Examples

The program osmchange is used for different projects which rely on up-to-date OSM XML files. The Wiki page Daily update an OSM XML file describes the update process in detail.

Resources

Main Memory

The program itself will occupy only a few MB. If you use several .osc files simultaneously, 20 MB per input file will be needed. When applying geographical borders (parameters -b and -B) another 400 MB are needed for a hash memory. You can change the hash memory size with the parameter -h..., e.g. -h1000.

Benchmarks

(Please add comments.)