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.2.tar.gz (21.8 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.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osmviews-0.2.2.tar.gz
  • Upload date:
  • Size: 21.8 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.2.tar.gz
Algorithm Hash digest
SHA256 6c0d9c86ec2e0eb0473e351ea83ef3cd57b64ff944add2c09b0aeea7c3808aa1
MD5 2c841cf6f860ecb939eddd0a8a892e2b
BLAKE2b-256 3449bc45d25f3ff09ad887da32d34e3a21f44d66661c8452b131fdcf93e5da5f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: osmviews-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d1df0ee16ad968fb788dc61dcac95d8534c1802777fe1bbc456beb26e50ae1d3
MD5 fa5c273f32e5f6155bf9b2418f56a7fb
BLAKE2b-256 5267ce914fbd6d0f749b540036b7a81d5490171bd038183738c1a3abfa05f966

See more details on using hashes here.

Provenance

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

This release

0.2.2 This release

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