What's the best way of performing a tag transformation on a .osc file?

With "osmosis" I can do something like:

osmosis --read-pbf before.pbf --tag-transform transform_cy.xml --write-pbf after.pbf

(see here for an example).

That works fine for pbfs. "osmosis" does support "--read-xml-change" but unfortunately:

osmosis --read-xml-change before.osc --tag-transform transform_cy.xml --write-xml-change after.osc

gives an error:

org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task 2-tag-transform does not support data provided by default pipe stored at level 1 in the default pipe stack.

suggesting that transformations aren't supported for osmchange files.

"osmfilter" doesn't seem to like osmchange fies at all:

osmfilter before.osc --modify-tags="name:cy to name" -o=after.osc


osmfilter Warning: unexpected end of input file: before.osc

"osmium" has some documentation but it does not mention tag transformations.

asked 10 May, 17:32

SomeoneElse's gravatar image

SomeoneElse ♦
accept rate: 16%

The tongue it cheek answer is "vi" or, automated "sed" :-).

I suppose if any of the tools supports JOSM style OSM .xml format (that is supports negative ids and doesn't bork on the action attribute) you could apply the ocs file, transform the tags, extract the ocs file again.

(11 May, 07:36) SimonPoole ♦

This is not a complete answer, but maybe it helps you to get towards a solution:

  1. Osmium can transform any OSM file into OPL format and back. The OPL format is a simple text format with one line per OSM object which makes it very easy to do transformations with sed or similiar tools on the command line, or even a small script of your favourite scripting language. The OPL format was specifically designed to allow these kinds of things. For more, see the documentation.
  2. If you like Python, you can use PyOsmium and write a little program to do the transformations.
  3. Unlike Osmosis which handles .osm and .osc files differently, they are handled in the same way in Osmium internally. Only when reading and writing a file it chooses the different format based on the file name suffix. You might be able to "convert" the .osc file into an .osm file and then Osmosis won't notice what it is working on. After that you use Osmium to "convert" it back. That's just an idea, you have to experiment to see whether you can get this to work.
permanent link

answered 11 May, 08:21

Jochen%20Topf's gravatar image

Jochen Topf
accept rate: 32%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 May, 17:32

question was seen: 169 times

last updated: 11 May, 08:21

powered by OSQA