Skip to main content

osmviews

PyPI Python versions CI OpenSSF Scorecard

Python client for OSMViews, a world-wide ranking of geographic locations by how much they are looked at on OpenStreetMap-based maps. See the main project for background.

OSMViews aggregates a year of OpenStreetMap map-tile access logs into a single raster covering the whole planet. This package reads a copy of that raster from local disk and answers point queries.

Usage

# pip install osmviews
import osmviews

with osmviews.open("osmviews.tiff") as o:
    # rank() is 0.0 (nobody looks here) to 1.0 (one of the most-viewed places on
    # Earth). Coordinates are x, y — longitude then latitude, as in GeoJSON;
    # values drift weekly.
    shibuya = o.rank(139.7013, 35.6586)  # Tokyo, Shibuya     ~0.69
    altstetten = o.rank(8.4889, 47.3915)  # Zürich, Altstetten ~0.66
    ushuaia = o.rank(-68.3030, -54.8019)  # Ushuaia            ~0.56
    sahara = o.rank(13.0000, 23.0000)  # Sahara             ~0.00
    assert shibuya > altstetten > ushuaia > sahara

The package does not download anything. Fetch the dataset (~594 MB, regenerated weekly) from osmviews.DOWNLOAD_URL however you like, then pass the path to osmviews.open.

An OSMViews instance is safe to share across threads: every query takes a lock only briefly, and tile decoding happens outside it. Decoded tiles are kept in a small LRU cache (osmviews.open(path, cache_tiles=...), 0 disables it), so queries clustered in one region stay fast. o.metrics() returns a snapshot of counters (cache hit rate, decode time, …) worth logging at the end of a long run.

The file is memory-mapped, so it must not be modified or truncated while an OSMViews is open.

Performance

Rough numbers on an Apple M5, CPython 3.13 (from benchmarks/bench.py): rank() returns in ~0.5 µs when the tile is already cached and ~57 µs on a miss that has to read and inflate one. Each decoded tile is 256 KiB; the default LRU holds 64 of them (~16 MiB), and the GeoTIFF is memory-mapped rather than read onto the heap. For bulk lookups, submit points in roughly spatial order (e.g. sorted by tile or by S2 cell ID) so neighbouring queries reuse cached tiles.

This is pure Python; it is not trying to be fast. If throughput matters, the Rust client answers the same query in tens of nanoseconds.

No dependencies

Pure Python 3.11+, standard library only (mmap, zlib, struct, array). The TIFF header parsing and the map projection are done in-package.

Contributing

Contributions are welcome — see CONTRIBUTING.md. The design and its rationale are written up in TECHNICAL_DESIGN.md.

Sponsoring

This package and the OSMViews pipeline behind it are maintained by Sascha Brawer as a volunteer effort. If your project relies on them, please consider sponsoring continued maintenance and future development via GitHub Sponsors.

License

MIT — see LICENSE.

Download files

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

Source Distribution

osmviews-0.2.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osmviews-0.2.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file osmviews-0.2.1.tar.gz.

File metadata

  • Download URL: osmviews-0.2.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for osmviews-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d59c917d583c0c79858cf427ea09723e58683fd8190f2b59d2d0806926d581e6
MD5 52b521297c9e571799fef6bebec7ef53
BLAKE2b-256 6b523930dea9aa1d5853e71f8c1622e99712352a48e4f161eb7122ed03790cd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmviews-0.2.1.tar.gz:

Publisher: publish.yml on brawer/osmviews-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osmviews-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: osmviews-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for osmviews-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f08b524de47282208ed601ffc6a7e1977d0d28175f2619cf3b6d0cdd1547ad88
MD5 8e0361c325729a4bac359d3c3da60c62
BLAKE2b-256 0d12c498933fbd3a8a6187d51dcd346829d5328572d59fdef49e70780aea50e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmviews-0.2.1-py3-none-any.whl:

Publisher: publish.yml on brawer/osmviews-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.2

2 files

This release

0.2.1 This release

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

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