I am trying to filter a .pbf file with Osmium. I can extract all the features with the tag /admin_level=2, but I want to filter even further by specifying the name, because there are some cases where the dump for Geofabrik contains more than one country (for example, Senegal and Gambia).

Here is my command:

osmium tags-filter osm.pbf /admin_level=2 /name:en=Senegal --overwrite --output boundary.pbf

It executes successfully, yet when I load it into a PostGIS database with osm2pgsql, I still have Senegal and Gambia:

enter image description here

Am I not specifying the tag filter right? It looks fine to me according to the docs

Versions output is:

osmium version 1.11.1
libosmium version 2.15.4
Copyright (C) 2013-2019  Jochen Topf <jochen@topf.org>
License: GNU GENERAL PUBLIC LICENSE Version 3 <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

1 Answer 1


In Osmium separate filter expressions <type>/<expression_1> <type>/<expression_2> ... are treated as logically disjunct (OR) operations.

In order to get a logically conjunct (AND) set from your filters, you need to chain them into one filter expression:

osmium tags-filter osm.pbf /name:en=Senegal,admin_level=2 --overwrite --output boundary.pbf


Actually, that is not true - there is no AND, and this is the second time I made this mistake...

You will have to generate intermediate files between subsequent calls to osmium tags-filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.