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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cog2tiles-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c897c573dfdfbbc61ab3e46d8a6d9ddd389f13cceb6f7617955bdb0815352f43
MD5 f9c165fc0256175e905af3b410fdcb1e
BLAKE2b-256 8fd64aa0288c5fe130827c12e2cf7dc86089f923994bf3e3b2b49a595c8ebbb8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cog2tiles-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7786d0e0d3ac9081f458eb4b0d66f1ade8f4a7f5eb55abbe53d32ad4e3fdae2
MD5 26e7872abbbd424ad3a6d6c5e976bef4
BLAKE2b-256 60a22207489bace09df1d3647352abdeeb2f5171742bd79af4a4ca8c152c2471

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