Skip to main content

Taginfo

This project exists to access magnificent taginfo maintained by Jochen Topf.

It is an unofficial Python wrapper over available API.

It is a Python wrapper for a tiny part of taginfo API that I use in my projects.

Note that the taginfo API is intended for the use of the OpenStreetMap community. Do not use it for other purposes. (source) As taginfo is open source you can deploy own service of needed.

Installation

Like any other python package: pip install taginfo

Examples

How often given key is used?

import taginfo

key = "name:ab"
print(key, "is used", taginfo.query.count_appearances_of_key(key), "times")

What about tags?

import taginfo

key = "horse"
value = "noo"
print(key, "=", value, "is used", taginfo.query.count_appearances_of_tag(key, value), "times")
value = "no"
print(key, "=", value, "is used", taginfo.query.count_appearances_of_tag(key, value), "times")
import taginfo

key = "bin"
print("all values of specific key:")
for value in taginfo.query.values_of_key(key):
    print(key, "=", value)
print()
key = "surface"
print("all popular values of specific key:")
for entry in taginfo.query.values_of_key_with_data(key):
    if(entry['count'] > 1000):
        print(key, "=", entry['value'], str(int(entry['count']/1000)) + "k")

See https://github.com/openstreetmap/id-tagging-schema/issues/1641 for output

See test_tags_used_in_project in tests.py for code used to generate it.

# no issue created for it at https://github.com/openstreetmap/id-tagging-schema/issues
# right now it provides no useful info (more entries need to be skipped or verified)
project = "id_editor"
supported = []
threshold = 500_000
expected_support = []
for entry in taginfo.query.tagging_used_by_project(project):
    if entry["key"] not in supported:
        supported.append(entry["key"]) # will not catch cases where only specific value is supported
page = 1
finished = False
while not finished:
    for entry in taginfo.query.get_page_of_all_keys_with_wiki_page(page):
        if(entry['count_all'] < threshold):
            finished = True
            break
        key = entry["key"]
        banned_key_prefix_indicating_import_garbage = ["tiger:", "nhd:", "NHD:", "lacounty:", "ref:", "nysgissam:", "nycdoitt:", "yh:", "building:ruian:", "gnis:", "osak:", "maaamet:", "chicago:", "LINZ:"]
        matches_blacklisted = False
        for prefix in banned_key_prefix_indicating_import_garbage:
            if key.find(prefix) == 0:
                matches_blacklisted = True
                break
        if matches_blacklisted:
            continue
        if key in [
            "created_by", # deprecated/discardable, not listed in iD taginfo project
            "is_in", # deprecated and unwanted
            "name_1", # weird tagging promoted by old iD versions
            "addr:TW:dataset", # unwanted import tag
        ]:
            continue
        if key not in supported:
            formatted_count = str(int(entry["count_all"]/1000))+"k"
            print(key, formatted_count)
            expected_support.append({"key": key, "count": formatted_count})
    page += 1

for entry in expected_support:
    link = "https://taginfo.openstreetmap.org/keys/" + entry["key"]
    text = "`" + entry["key"] + "` " + entry["count"]
    linked_markdown_text = "[" + text + "](" + link + ")"
    print(linked_markdown_text)

Historic data

import taginfo

print("Intended to show useful info (and maybe motivate you to talk to this mappers and ask whether they meant surface=concrete:")
print(taginfo.query.count_new_appearances_of_tag_historic_data("surface", "cement", 60), "net change for surface=cement within last 60 days (this tag appears to be duplicating surface=concrete)")
print()
print("intended to show that such short-term queries are likely to be a problem, as taginfo may have delay in updating and last few days may be often unavailable:")
print(taginfo.query.count_new_appearances_of_key_historic_data("building", 1), "new building=* objects since yesterday")

Development

Contributions are welcome to cover larger part of taginfo API.

Run tests

python3 -m unittest

Metadata

Release files for taginfo 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taginfo 0.0.5
File Size Uploaded Provenance
taginfo-0.0.5.tar.gz 6.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for taginfo 0.0.5
File Interpreter ABI Platform
taginfo-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / taginfo-0.0.5.tar.gz

Download URL taginfo-0.0.5.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7dd0b1eccd5027d20008663cb5a8ab8b44e67d5fa503e887c3c571b1a7e59b96
BLAKE2b-256 checksum
How to use checksums
b4cd4265e9ff189c583a981c9d1b83b84b1d002a9c7fe00febd1a1e76c8f8c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / taginfo-0.0.5-py3-none-any.whl

Download URL taginfo-0.0.5-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
866e4d1149726eee28a66f30d85b0c653e267dff125b5cb5cbcd1b7fb3e99bb3
BLAKE2b-256 checksum
How to use checksums
3275ed26c1cca3867e754f25740305d7782cede426ef8de2db838f699d3ee1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for taginfo 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page