Skip to main content

osmviews

PyPI Python versions CI OpenSSF Scorecard REUSE status

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. o.date gives the last day of OpenStreetMap tile-log data in the raster (a datetime.date), so you can tell which week's views you have.

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.

The repository is REUSE compliant: every file declares its copyright and license, either in an SPDX header or via REUSE.toml. All code and documentation is MIT; the sole exception is CODE_OF_CONDUCT.md, adapted from the Contributor Covenant and licensed CC-BY-SA-4.0. It is not part of the published package.

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.3.tar.gz (23.4 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.3-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osmviews-0.2.3.tar.gz
  • Upload date:
  • Size: 23.4 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.3.tar.gz
Algorithm Hash digest
SHA256 9d88a02b908638d1a244698f66f2d5559dd8e62a053ecf74a5953b44e5edafe4
MD5 85dc15425925b91e7a8b2fe143b6911b
BLAKE2b-256 f6928bfb95f7267a7ad7799c66593cd2230f0e8d0a61cc20be9b6856cbb14521

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmviews-0.2.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: osmviews-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 02f1db5679a9c05f3ca3803e8a64c06e84408e43322b5ae2a3144648a1fb6c41
MD5 3bffb1e513e5e6d69637efcc282e0ac4
BLAKE2b-256 c317efe71ab5b12a037095887488e0b9d88cd6be041e009a1859afc348c89b5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmviews-0.2.3-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

This release

0.2.3 This release

2 files

0.2.2

2 files

0.2.1

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