OSMIUM-TAGS-COUNT(1) | OSMIUM-TAGS-COUNT(1) |
osmium-tags-count - count keys/tags
osmium tags-count [OPTIONS] OSM-FILE [TAG-EXPRESSION...]
osmium tags-count [OPTIONS] --expressions=FILE OSM-FILE
Count how often keys or tags appear in the input file. If the only command line argument is an OSM file, all keys in this file are counted. If there are one or more tag expressions on the command line, only the keys and tags matching those expressions are counted.
See the TAG EXPRESSIONS section for a description of the expression format.
The output has one line per key/tag found. Each line contains the count, the tag key, and the tag value (if matching tags) separated by TAB characters. Tag keys and values are surrounded by double quotes. Any double quotes in the keys and values are doubled.
A filter expression specifies one or more keys and/or tags that should be counted in the data.
Some examples:
If there is 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 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. 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 “,”. You can not mix comma-expressions and “*”-expressions.
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.
osmium tags-count exits with exit code
osmium tags-count keeps all counters in memory. For a large OSM file and unrestricted keys or, worse, tags, this can use quite a lot of memory. (Counting all tags on a full planet file will use about 16 GByte RAM.)
Use the filter expressions to restrict the counting to the keys or tags you are actually interested in.
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 '*=*'
Copyright (C) 2013-2021 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.
If you have any questions or want to report a bug, please go to https://osmcode.org/contact.html
Jochen Topf <jochen@topf.org>.
1.13.1 |