osmviews
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c0d9c86ec2e0eb0473e351ea83ef3cd57b64ff944add2c09b0aeea7c3808aa1
|
|
| MD5 |
2c841cf6f860ecb939eddd0a8a892e2b
|
|
| BLAKE2b-256 |
3449bc45d25f3ff09ad887da32d34e3a21f44d66661c8452b131fdcf93e5da5f
|
Provenance
The following attestation bundles were made for osmviews-0.2.2.tar.gz:
Publisher:
publish.yml on brawer/osmviews-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osmviews-0.2.2.tar.gz -
Subject digest:
6c0d9c86ec2e0eb0473e351ea83ef3cd57b64ff944add2c09b0aeea7c3808aa1 - Sigstore transparency entry: 2664203129
- Sigstore integration time:
-
Permalink:
brawer/osmviews-py@837c3f281171f7e4f46ff7f00f71477b69a67cfe -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/brawer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@837c3f281171f7e4f46ff7f00f71477b69a67cfe -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1df0ee16ad968fb788dc61dcac95d8534c1802777fe1bbc456beb26e50ae1d3
|
|
| MD5 |
fa5c273f32e5f6155bf9b2418f56a7fb
|
|
| BLAKE2b-256 |
5267ce914fbd6d0f749b540036b7a81d5490171bd038183738c1a3abfa05f966
|
Provenance
The following attestation bundles were made for osmviews-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on brawer/osmviews-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osmviews-0.2.2-py3-none-any.whl -
Subject digest:
d1df0ee16ad968fb788dc61dcac95d8534c1802777fe1bbc456beb26e50ae1d3 - Sigstore transparency entry: 2664203190
- Sigstore integration time:
-
Permalink:
brawer/osmviews-py@837c3f281171f7e4f46ff7f00f71477b69a67cfe -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/brawer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@837c3f281171f7e4f46ff7f00f71477b69a67cfe -
Trigger Event:
push
-
Statement type: