Skip to main content

COG to web map tiles converter with concurrent processing

Project description

cog2tiles

Cloud Optimized GeoTIFF (COG) to web map tiles converter built with modern Python.

Installation

Using uv (recommended)

git clone https://github.com/kshitijrajsharma/cog2tiles.git
cd cog2tiles
uv sync

Using pip

pip install cog2tiles

Usage

Command Line Interface

Basic usage:

cog2tiles input.tif -z 19

Advanced usage:

cog2tiles input.tif -z 19 --tile-size 512 --extension png --output-dir tiles/ --workers 64

Options

  • input_cog: Path to input COG file
  • -z, --zoom: Target zoom level (0-22)
  • -o, --output-dir: Output directory (default: tiles)
  • --tile-size: Tile size in pixels, 256 or 512 (default: 256)
  • --prefix: Filename prefix for tiles (default: tile)
  • --extension: Output format - png, jpg, webp (default: png)
  • --workers: Maximum concurrent workers (default: auto-detected)
  • --log-level: Logging level - DEBUG, INFO, WARNING, ERROR (default: INFO)

Python API

import asyncio
from cog2tiles import COGTiler

async def main():
    tiler = COGTiler(
        tile_size=512,
        max_workers=32,
        extension="webp"
    )
    
    await tiler.convert_to_tiles("input.tif", "output/", zoom=19)

asyncio.run(main())

Requirements

  • Python 3.11 or higher
  • GDAL/rasterio for geospatial operations
  • Numba for accelerated processing
  • UV for dependency management
  • uvloop for the fast asyncio loops (optional)

Development

Setup Development Environment

git clone https://github.com/kshitijrajsharma/cog2tiles.git
cd cog2tiles
uv sync --dev

Running Tests

uv run pytest

Code Formatting

uv run black src/
uv run isort src/

Supported Input Formats

  • Cloud Optimized GeoTIFF (COG)
  • Any rasterio-supported format with proper georeferencing

Output Formats

  • PNG (lossless, supports transparency)
  • JPEG (lossy, smaller file sizes)
  • WebP (modern format, good compression)

License

MIT License - see LICENSE file for details.

Author

Kshitij Raj Sharma (2025)

Project details


Download files

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

Source Distribution

cog2tiles-0.0.4.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

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

cog2tiles-0.0.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file cog2tiles-0.0.4.tar.gz.

File metadata

  • Download URL: cog2tiles-0.0.4.tar.gz
  • Upload date:
  • Size: 69.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for cog2tiles-0.0.4.tar.gz
Algorithm Hash digest
SHA256 60f368ab24451121e073bb3f0218025275e996cb08db0444811708373a1ddd75
MD5 8068a4c41cd7f6ac10730969cb22e27e
BLAKE2b-256 509c3365670df62aac87eadbc6492f477fc84035a14740ce98c61ea99cf24064

See more details on using hashes here.

File details

Details for the file cog2tiles-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: cog2tiles-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for cog2tiles-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d35591babc59b55165c94469d94d685a0c09c8e26a9306d67d8e2bd10f7993bd
MD5 f0447a7eb11b87b1c4b0c60512a4de3e
BLAKE2b-256 c06086a44701a489f45072e4b70845d5833a32c8058e1574d6610c7b51cca2f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page