I am trying to get all main railway tracks from an .osm.pbf file. My command looks like this:

osmium tags-filter austria-latest.osm.pbf railway=rail railway:track_type=main service!=yard service!=siding -o rails_in_austria.osm.pbf

My expectation was that osmium will match the file against all four filter expressions sequentially similar to a logical & operator. Somehow this doesn't seem to happen as my result contains entries that e.g. do not contain any railway attribute.

The man page for osmium-tags-filter says:

The filter expressions specified in a file and/or on the command line are matched in the order they are given. To achieve best performance, put expressions expected to match more often first.

I'm stuck here, maybe more experienced users can help?

In QGis my filter works with following SQL filter expression:

"other_tags" LIKE '%"railway:track_type"=>"main"%' AND "other_tags" NOT LIKE '%"service"=>"yard"%' AND "other_tags" NOT LIKE '%"service"=>"siding"%'

asked 25 Dec '21, 13:29

pato3's gravatar image

accept rate: 0%

The first sentence of the man page should make things clear: "Get objects matching at least one of the specified expressions from the input and write them to the output." So the expressions are ORed together. You can not do general AND expressions. Sometimes what you want can be done using inverted expressions and the -i option. Or you run Osmium several times, once each with the expressions you want ANDed.

Generally osmium tags-filter is more suited to to a rough filtering (in your case the railway=rail) which will reduce the data from "huge amounts of data" to "manageable amount of data" quickly. Then just use any other kind of specialized processing you want to do with whatever tool suits you best.

permanent link

answered 25 Dec '21, 17:25

Jochen%20Topf's gravatar image

Jochen Topf
accept rate: 31%

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: 25 Dec '21, 13:29

question was seen: 832 times

last updated: 25 Dec '21, 17:25

Related questions

powered by OSQA