OSMIUM-TAGS-COUNT(1)

๐Ÿ’– osmium-tags-count(1) ๐Ÿ’–

okay bestie, sit down, hydrate, because we're about to count keys and tags and it's gonna be so satisfying. this is the manual page for osmium-tags-count, part of the osmium fam (version 1.19.1, mwah ๐Ÿ’‹).


โœจ NAME โœจ

osmium-tags-count โ€” count keys/tags ๐Ÿงฎ๐Ÿ’…


โœจ SYNOPSIS โœจ

osmium tags-count [OPTIONS] OSM-FILE [TAG-EXPRESSION...]
osmium tags-count [OPTIONS] --expressions=FILE OSM-FILE

โœจ DESCRIPTION โœจ

So like. This command counts how often keys or tags show up in the input file. That's it, that's the whole vibe. ๐ŸŽ€

If the only command line argument is an OSM file, then every single key in that file gets counted. But if you hand it one or more tag expressions on the command line, then only the keys and tags that match those expressions get counted. picky queen behavior, we respect it ๐Ÿ‘‘

Wanna know what the expression format looks like? Scroll down to TAG EXPRESSIONS, bestie, it's all there.

The output is one line per key/tag that got found. Each line has: the count, the tag key, and the tag value (only if we're matching tags) โ€” all separated by TAB characters. Tag keys and values are wrapped in double quotes. And any double quotes inside the keys and values get doubled. yes, doubled. it's giving escape-the-escape ๐Ÿ’€


โœจ OPTIONS โœจ

  • -e FILE, --expressions=FILE โ€” read expressions from that file, one per line. Empty lines? ignored, they're not the main character. Everything after the comment character (#) is ignored too. More deets live in TAG EXPRESSIONS.
  • -m COUNT, --min-count=COUNT โ€” the minimum count that should show up in the output. Use this when you only care about the common keys/tags, aka the popular girls ๐Ÿซถ
  • -M COUNT, --max-count=COUNT โ€” the maximum count that should show up in the output. Use this when you're only interested in the rare keys/tags โ€” the underrated indie darlings ๐Ÿฆ‹
  • -s SORT, --sort=SORT โ€” sort order, babes. Order by count-asc, count-desc, name-asc, or name-desc. Default is count-desc. (most popular first, iconic behavior)
  • -t, --object-type=TYPE โ€” read only objects of the given type (node, way, relation). By default all types are read. You can give this option multiple times, stack it up like bracelets โœจ

๐ŸŒธ COMMON OPTIONS ๐ŸŒธ

  • -h, --help โ€” show usage help. we love a supportive king.
  • -v, --verbose โ€” set verbose mode. The program will output information about what it is doing to STDERR. it's narrating its own life, honestly relatable ๐Ÿ˜ญ
  • --progress โ€” show a progress bar. Usually a progress bar is only displayed if STDOUT and STDERR are detected to be TTY. With this option a progress bar is always shown. Note that a progress bar will never be shown when reading from STDIN or a pipe. never ever. periodt.
  • --no-progress โ€” do not show the progress bar. Usually a progress bar is displayed if STDOUT and STDERR are detected to be a TTY. With this option the progress bar is suppressed. Note that a progress bar will never be shown when reading from STDIN or a pipe. (yes it's the same caveat, no I'm not skipping it ๐Ÿ’…)

๐ŸŒˆ INPUT OPTIONS ๐ŸŒˆ

  • -F, --input-format=FORMAT โ€” the format of the input file(s). Use this to set the input format when it can't be autodetected from the file name(s). Heads up though: this sets the format for all input files, there is no way to set the format for some input files only. all or nothing, bestie ๐Ÿ˜ค See osmium-file-formats(5) or the libosmium manual for the details.

๐ŸŽ€ OUTPUT OPTIONS ๐ŸŽ€

  • -o, --output=FILE โ€” name of the output file. Default is - (STDOUT). the classic.
  • -O, --overwrite โ€” allow an existing output file to be overwritten. Normally osmium will refuse to write over an existing file โ€” it's got boundaries, unlike some people ๐Ÿ™ˆ

๐Ÿ’œ TAG EXPRESSIONS ๐Ÿ’œ

A filter expression specifies one or more keys and/or tags that should be counted in the data. simple as that, no cap.

Some examples, and yes they're all exactly like this:

  • amenity โ€” matches the key amenity.
  • highway=primary โ€” matches the tag with key highway and value primary.
  • highway!=primary โ€” matches any tag with key highway and a value other than primary. (the exclamation is doing the "not" thing, iykyk)
  • type=multipolygon,boundary โ€” matches any tag with key type and value multipolygon or boundary.
  • name,name:de=Kastanienallee,Kastanienstrasse โ€” matches any tag with the key name or name:de with the value Kastanienallee or Kastanienstrasse.
  • addr:* โ€” matches tags with keys starting with addr:
  • name=*Paris โ€” matches all tags with key name and a value that contains the word Paris.

Okay so here's the rules of the game ๐Ÿงš:

If there's no equal sign (=) in the expression, only keys are matched and values can be anything. If there is an equal sign (=) in the expression, the key is to the left and the value is to the right. An exclamation sign (!) before the equal sign means: a tag with that key, but not the value(s) to the right of the equal sign. A leading or trailing asterisk (*) can be used for substring or prefix matching, respectively. And commas (,) can be used to separate several keys or values.

All filter expressions are case-sensitive. There is no way to escape the special characters such as =, * and ,. And you can not mix comma-expressions and *-expressions. nope. not happening. ๐Ÿšซ

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. (front-load your bangers, bestie ๐Ÿ”ฅ)


๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

osmium tags-count exits with exit code

  1. 0 โ€” if everything went alright,
  2. 1 โ€” if there was an error processing the data, or
  3. 2 โ€” if there was a problem with the command line arguments.

๐Ÿง  MEMORY USAGE ๐Ÿง 

osmium tags-count keeps all counters in memory. So for a large OSM file and unrestricted keys or, worse, tags, this can use quite a lot of memory. And when I say quite a lot I mean: (counting all tags on a full planet file will use about 16 GByte RAM.) yeah. sixteen. gigabytes. ๐Ÿ˜ญ

Use the filter expressions to restrict the counting to the keys or tags you are actually interested in. your RAM will thank you ๐Ÿซถ


โญ EXAMPLES โญ

Count all keys in Spain and display most common keys first:

osmium tags-count spain.osm.pbf

Count all building keys in Madrid:

osmium tags-count madrid.osm.pbf building

Count all building tags on ways in Madrid, order by name:

osmium tags-count -t way --sort=name-asc madrid.osm.pbf 'building=*'

Count all relation types in Sevilla that appear at least 100 times:

osmium tags-count -t relation -m 100 sevilla.osm.pbf 'type=*'

Count all tags in the input file. Note that this might need quite a lot of memory!

osmium tags-count input.osm.pbf '*=*'

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


Copyright (C) 2013-2026 Jochen Topf <jochen@topf.org>.

License GPLv3+: GNU GPL version 3 or later <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. (fr fr, no warranty, read it and weep)


๐Ÿ“ฌ CONTACT ๐Ÿ“ฌ

If you have any questions or want to report a bug, please go to https://osmcode.org/contact.html


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Jochen Topf <jochen@topf.org>.


and that's the whole page, bestie!! this was version 1.19.1 of osmium-tags-count(1) โ€” go forth and count your keys, you absolute icon ๐Ÿฆ‹โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from