Skip to main content

A small wrapper around taginfo API

Project description

Taginfo

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

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 services. (source)

Examples

Listing popular values for key

import taginfo

key = "landuse"
for value in taginfo.query.values_of_key(key):
    print(key, "=", value)
print()
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")

Listing popular tags unsupported by iD

import taginfo

def show_popular_tags_not_supported_by_project(project, key, excluded_values, threshold):
    expected_support = []
    cached_value_info = {}
    for entry in taginfo.query.values_of_key_with_data(key):
        if(entry['count'] > threshold):
            expected_support.append(entry["value"])
            cached_value_info[entry["value"]] = entry
    for entry in taginfo.query.tagging_used_by_project(project):
        if entry["key"] == key:
            if(entry["value"] != None):
                if entry["value"] in expected_support:
                    expected_support.remove(entry["value"])

    for entry in expected_support:
        if entry not in excluded_values:
            link = "https://taginfo.openstreetmap.org/tags/" + key + "=" + entry
            text = key + " = " + cached_value_info[entry]['value'] + " " + str(int(cached_value_info[entry]['count']/1000)) + "k"
            linked_markdown_text = "[" + text + "](" + link + ")"
            print(linked_markdown_text)

project = "id_editor"
show_popular_tags_not_supported_by_project(project, "building", ["yes"], 100_000)
show_popular_tags_not_supported_by_project(project, "shop", ["yes", "no"], 1_000)
show_popular_tags_not_supported_by_project(project, "natural", [], 6_000)
show_popular_tags_not_supported_by_project(project, "leisure", [], 5_000)
show_popular_tags_not_supported_by_project(project, "amenity", [], 5_000)
show_popular_tags_not_supported_by_project(project, "landuse", [], 5_000)
show_popular_tags_not_supported_by_project(project, "power", [], 2_000)
show_popular_tags_not_supported_by_project(project, "place", [], 10_000)
show_popular_tags_not_supported_by_project(project, "railway", ["razed", "proposed"], 5_000)
show_popular_tags_not_supported_by_project(project, "barrier", [], 3_000)
show_popular_tags_not_supported_by_project(project, "highway", ["proposed", "no"], 1_000)
show_popular_tags_not_supported_by_project(project, "tourism", [], 1_000)
show_popular_tags_not_supported_by_project(project, "waterway", [], 5_000)

Development

Contributions are welcome to cover larger part of taginfo API. s

Run tests

python3 -m unittest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taginfo-0.0.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

taginfo-0.0.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file taginfo-0.0.3.tar.gz.

File metadata

  • Download URL: taginfo-0.0.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.28.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.10

File hashes

Hashes for taginfo-0.0.3.tar.gz
Algorithm Hash digest
SHA256 39b9310f4ecf5224f2ffd67488552d66ab9897014695f39db77a1c5de1a6a54a
MD5 c945abcb0365a58cafb594eb2aa5c47f
BLAKE2b-256 7457a39b7a920c2ab9f1f8f183e8bd57e9e75d424b93b6a6dac3ceb7453c8e10

See more details on using hashes here.

File details

Details for the file taginfo-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: taginfo-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.28.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.10

File hashes

Hashes for taginfo-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f640ef32cbd0524434abec513aaab45405fc5ac464031607b81e12198245669
MD5 fe6114cf392c8155c9e69ba86baef8ac
BLAKE2b-256 2c15d16f98bb484140d623789fa3b495323d80a3ae98d8997833f691883e5f35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page