NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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

gives

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

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

asked 10 May '20, 17:32

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
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 '20, 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 '20, 08:21

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

Follow this question

By Email:

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

By RSS:

Answers

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:

×252
×60
×38
×5
×4

question asked: 10 May '20, 17:32

question was seen: 2,472 times

last updated: 11 May '20, 08:21

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum