A tile downloader utility
Project description
Tile Downloader
A Python library for downloading map tiles from tile servers such as OpenStreetMap or other XYZ tile services. It supports multithreaded downloading, retry logic, bounding box-based selection, and optional WebP conversion.
Features
- Convert bbox to tile coordinates
- Download tiles in parallel using threads
- Retry on network failures with exponential backoff
- Save tiles in organized folder structure
- Optional conversion to
.webpformat for optimized storage - Logs failed downloads to CSV
Installation
Install the package via pip:
pip install tile-downloader
Usage
from tile_downloader import TileDownloader
# Initialize downloader
downloader = TileDownloader(
tile_server_url_template="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
save_dir="./tiles",
num_workers=20,
convert_to_webp=True
)
# Define bounding box (lat_min, lon_min, lat_max, lon_max)
bbox = (35.0, 51.0, 36.0, 52.0)
# Download tiles for zoom levels 12 to 14
downloader.download_tiles_from_bbox(bbox, zoom_levels=[12, 13, 14])
Parameters
| Parameter | Type | Description |
|---|---|---|
tile_server_url_template |
str |
URL template with {z}, {x}, {y} placeholders |
save_dir |
str |
Directory to save downloaded tiles |
num_workers |
int |
Number of threads (default: 10) |
convert_to_webp |
bool |
Convert downloaded PNGs to WebP (default: False) |
Output Structure
Tiles are saved in:
save_dir/
{z}/
{x}/
{y}.png (or .webp)
Example: tiles/12/2345/1546.png
Error Logging
Failed downloads are saved to a CSV file named download_errors.csv in the root directory with columns:
- zoom
- x
- y
- error
License
This project is licensed under the MIT License © 2025 A.Talebifard – see the LICENSE file for details.
Author
A.Talebifard – abbastalebifard@gmail.com
Feel free to contribute, report issues, or suggest improvements!
Project details
Release history Release notifications | RSS feed
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 tile_downloader-0.16.tar.gz.
File metadata
- Download URL: tile_downloader-0.16.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
592354f5cfa8098c099652de124d4b3c7cc22b5209779b97b09de122698fc908
|
|
| MD5 |
c926126ea2a40a7db9d7de7c000736ce
|
|
| BLAKE2b-256 |
e81637733f6b335ee8c2c5c054f7a80f9fdbf371098bae6adb6dd06435ee9bf4
|
File details
Details for the file tile_downloader-0.16-py3-none-any.whl.
File metadata
- Download URL: tile_downloader-0.16-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daef8c05a80c21cf670909ca3303d3a263b76600660edaaef2817a38169348e9
|
|
| MD5 |
6a9a2dbe07c6eef4b68f3b84bdfcc210
|
|
| BLAKE2b-256 |
ffaa792f4b1aad8b9c785eacebd4bb318fef9feecc4bd9b2683da73cff293fa8
|