cog-tiles for Python
Web map tiles and stitched rasters from tile-aligned Cloud Optimized GeoTIFFs (COGs), local or in
S3, GCS, Azure or over HTTP, fetching only the bytes each tile needs.
Python bindings for the Rust cog-tiles crate used by
Martin.
import cog_tiles
cog = cog_tiles.open("s3://bucket/ortho.tif", options={"aws_region": "us-west-2"})
cog.min_zoom, cog.max_zoom, cog.tile_size, cog.format, cog.bounds
# One encoded tile, ready to serve or store (JPEG/WebP as stored, others as PNG).
png = cog.tile(18, 41936, 101296)
# Every tile in an area, fetched 64 at a time in the background, in arrival order.
for z, x, y, data in cog.tiles(bbox=(-122.42, 37.77, -122.41, 37.78), zoom=range(16, 19)):
...
# An area stitched into one (height, width, bands) uint8 array, decoded on all cores.
raster = cog.read((-122.42, 37.77, -122.41, 37.78), zoom=18)
raster.data.shape # (1311, 1166, 3)
raster.transform # GDAL geotransform in EPSG:3857
Many files, each covering one tile at a file zoom and named after it:
mosaic = cog_tiles.open_mosaic("s3://bucket/ortho/{quadkey}.tif", file_zoom=12)
raster = mosaic.read(bbox, zoom=18)
Templates use {quadkey}, or {x} and {y} with an optional {z} ({-y} counts rows from the
bottom, as in TMS). One file is found by listing the location when it is opened; the others are
opened on first use and cached.
With asyncio, e.g. in a tile server, every call that waits has an _async twin:
cog = await cog_tiles.open_async("s3://bucket/ortho.tif")
png = await cog.tile_async(18, 41936, 101296)
raster = await cog.read_async(bbox, zoom=18)
async for z, x, y, data in cog.tiles(bbox, zoom=18):
...
The fetches run on background threads, so awaited calls neither block the event loop nor hold a thread each.
What it reads
COGs on the WebMercatorQuad grid, as gdal_translate -of COG -co TILING_SCHEME=GoogleMapsCompatible
writes them: EPSG:3857, every image (and overview) at a zoom level's resolution and aligned to its
tiles, 8-bit samples. Each tile is one internal tile, so nothing is resampled. Other files raise
UnsupportedCogError saying why.
Performance
- All I/O and decoding runs in Rust with the GIL released;
readandtileskeepconcurrencyrequests in flight (64 by default) and decode on every core. - Wheels cover CPython 3.10 and later, including free-threaded CPython from 3.15t on.
- Headers are read once when opening (one request for a typical file); each tile is one range read.
tile_pixelsandreadhand their buffer to NumPy without copying.- Ctrl-C interrupts any call. Cancelling an
_asynccall or dropping atiles()iterator stops its pending fetches.
Details
bboxis(west, south, east, north)in degrees, or(min_x, min_y, max_x, max_y)in meters withcrs="EPSG:3857". A raster covers the whole pixels the bbox touches;raster.boundsis the snapped extent. Pixels without data are 0, and a bbox without any data returnsNone.readrefuses rasters overmax_pixels(16384 x 16384 by default).CogandMosaicobjects pickle by reopening, so they work inmultiprocessingand PyTorchDataLoaderworkers. Forked processes get their own I/O threads.- Object store credentials come from the usual environment variables (
AWS_*,GOOGLE_*,AZURE_*);optionsoverrides them withobject_storekeys, e.g.{"aws_skip_signature": "true"}for public buckets. - Errors:
FileNotFoundError,ValueErrorfor invalid arguments,UnsupportedCogErrorfor files that cannot be read as tiles,CogTilesErrorfor everything else.
Development
cd cog-tiles-py
uv venv && uv pip install maturin pytest numpy
uv run maturin develop --release
uv run pytest
cog_tiles.pyi is generated from the bindings by just sync-cog-py-stubs; autofix.ci regenerates it on pull requests.
Metadata
Release files for cog-tiles 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cog_tiles-0.1.0.tar.gz | 162.8 kB | Without provenance | Details |
Built distributions (wheels)
Total release size: 49.8 MB
Release files / cog_tiles-0.1.0.tar.gz
| Download URL | cog_tiles-0.1.0.tar.gz |
|---|---|
| Size | 162.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d5fbaf25f04dfcd082cc3172eec6c82deebbbc89233e5ed19ae0aa229e687a3
|
|
BLAKE2b-256 checksum How to use checksums |
a911ff0bddc0e92edbcf68b1ed85dc0c6d9dc8f0292b6463266ff18dbffaf7b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp315-abi3.abi3t-win_amd64.whl
| Download URL | cog_tiles-0.1.0-cp315-abi3.abi3t-win_amd64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.15 Windows x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
93d8e416eedf2eb62cf1caa7775933e914e6cfba39cc365b839ec7c04b98c535
|
|
BLAKE2b-256 checksum How to use checksums |
2ecf796b2591ef6553b4032b1ed403c5141a6d2e5b37ffa2a11bc1b7431735d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
| Download URL | cog_tiles-0.1.0-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
69e8aeec8da770864ff55aaabac2e3c85f6b26595aabdf445d7dd9a4778426ad
|
|
BLAKE2b-256 checksum How to use checksums |
10873d98c5b214a154eaa35b99969623a37eb95429db3e4c8b01e192bf77bdb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
| Download URL | cog_tiles-0.1.0-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ ARM64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
564b47c3314341f52b4a3a3a1af89b6c35b323c0489e17ae386c85c5408bbb89
|
|
BLAKE2b-256 checksum How to use checksums |
7c83d89df0b3c5ec0c021438ec61145c71ea396e6fd4f24a1b4032f68fbb2763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl
| Download URL | cog_tiles-0.1.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.15 abi3 abi3t macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ee8c2b87f9d0e8e2094112009c5e7fdf83774bd0eac5e61578310a11219f24f4
|
|
BLAKE2b-256 checksum How to use checksums |
8126c418327bdd0aaba61a2a68ba86ba105dde4ebfa298501d3404096ae17616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
| Download URL | cog_tiles-0.1.0-cp315-abi3.abi3t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.15 abi3 abi3t macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3395d25815bd43839198509b62025e9b64c5da10d72048a4973483a61d85096d
|
|
BLAKE2b-256 checksum How to use checksums |
c3a060473ea8e4352a8ec55e4c83606f1c8ad14eb813c63d9b1aac39747c3c5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp310-abi3-win_amd64.whl
| Download URL | cog_tiles-0.1.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e4e1f179aa041a40c22b66f3b49babf7a9554aec14d2085aeed7eab06da761d3
|
|
BLAKE2b-256 checksum How to use checksums |
086271b7d16faf097a5bee425df0057f36cfc61a961d6bfdf8d91ed7a558a8a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | cog_tiles-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bb56223d7fe907c081d97311abc426beb0185233f7cf068e3ebad1779da4ba43
|
|
BLAKE2b-256 checksum How to use checksums |
4a68417fb919301eaed3ec2808b3304bf04425323d7f7c6e179f27f28f3656e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | cog_tiles-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
12db6451a69303173b723b9c7ac58e283732160f0528ae7edfc262d49bb0c724
|
|
BLAKE2b-256 checksum How to use checksums |
6a43369066ab5457cd3bb6c8c8b116937dccb0b163d23ff3bc1b6d1ff2487c95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | cog_tiles-0.1.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
212c522142c5079f2c6861e9ade7cfc8d26a9d1e98445999593775709b984e10
|
|
BLAKE2b-256 checksum How to use checksums |
f412263a3822b455e0d8dc5ccaf8fb1bfda3f04def4c23fdf3e7f0ce1ecf50cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cog_tiles-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | cog_tiles-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
528fa427a1e2f77aa9dca6d20d100b9549e6827c4efd9d0e790924236f415c2c
|
|
BLAKE2b-256 checksum How to use checksums |
9b2e3fdd41378abbd51909b87bba1381c574383d65eaa464f764186b6b6e7b08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for cog-tiles 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.