| Crates.io | butterfly-dl |
| lib.rs | butterfly-dl |
| version | 2.0.0 |
| created_at | 2025-06-26 20:56:56.161573+00 |
| updated_at | 2025-06-27 08:23:21.323915+00 |
| description | Butterfly-dl - Optimized OpenStreetMap data downloader with HTTP support |
| homepage | https://github.com/butterfly-osm/butterfly-osm |
| repository | https://github.com/butterfly-osm/butterfly-osm |
| max_upload_size | |
| id | 1727820 |
| size | 160,585 |
A high-performance, memory-efficient OpenStreetMap data downloader with intelligent source routing, resilient networking, and beautiful progress display.
Download the latest release for your platform:
# Linux (x86_64)
wget https://github.com/butterfly-osm/butterfly-osm/releases/latest/download/butterfly-dl-v2.0.0-x86_64-linux.tar.gz
tar -xzf butterfly-dl-v2.0.0-x86_64-linux.tar.gz
sudo mv butterfly-dl-v2.0.0-x86_64-linux/butterfly-dl /usr/local/bin/
# macOS (Intel)
wget https://github.com/butterfly-osm/butterfly-osm/releases/latest/download/butterfly-dl-v2.0.0-x86_64-macos.tar.gz
tar -xzf butterfly-dl-v2.0.0-x86_64-macos.tar.gz
sudo mv butterfly-dl-v2.0.0-x86_64-macos/butterfly-dl /usr/local/bin/
# Windows
# Download butterfly-dl-v2.0.0-x86_64-windows.zip from releases page
wget https://github.com/butterfly-osm/butterfly-osm/releases/latest/download/butterfly-dl_2.0.0_amd64.deb
sudo dpkg -i butterfly-dl_2.0.0_amd64.deb
cargo install butterfly-dl
git clone https://github.com/butterfly-osm/butterfly-osm
cd butterfly-osm
cargo build --release -p butterfly-dl
This repository is organized as a Rust workspace containing multiple OSM tools:
# Build all tools
cargo build --workspace --release
# Build specific tool
cargo build --release -p butterfly-dl
# Test specific tool
cargo test -p butterfly-dl
# Download planet file from HTTP (81GB)
butterfly-dl planet
# Download continent from HTTP
butterfly-dl europe
# Download country/region from HTTP
butterfly-dl europe/belgium
# Stream to stdout for processing
butterfly-dl europe/monaco - | gzip > monaco.pbf.gz
# Save to custom file name
butterfly-dl planet planet-backup.pbf
# Verbose output with source info
butterfly-dl --verbose europe/belgium
# Smooth tqdm-style progress bars with comprehensive information
butterfly-dl europe/belgium
# 75%|โโโโโโโโโโโโโ | 450MB/600MB [01:30<00:30, 25.2MB/s]
# Automatic retry with smart resume - no lost progress
butterfly-dl europe/belgium
# โ ๏ธ Network error (attempt 1): operation timed out. Retrying in 1000ms...
# โ ๏ธ Stream interrupted at 300MB, resuming...
# โ
Download completed!
# Interactive prompts for existing files
butterfly-dl europe/belgium
# โ ๏ธ File already exists: belgium-latest.osm.pbf
# Overwrite? [y/N]: n
# โ Download cancelled
# Force overwrite without prompting
butterfly-dl europe/belgium --force
# โ ๏ธ Overwriting existing file: belgium-latest.osm.pbf
# Never overwrite, fail if file exists
butterfly-dl europe/belgium --no-clobber
# Error: File already exists: belgium-latest.osm.pbf (use --force to overwrite)
| Input | Source | Description |
|---|---|---|
planet |
HTTP | Planet file from https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf |
europe |
HTTP | Continent from https://download.geofabrik.de/europe-latest.osm.pbf |
europe/belgium |
HTTP | Country from https://download.geofabrik.de/europe/belgium-latest.osm.pbf |
butterfly-dl includes smart error correction with fuzzy matching:
# Semantic intent recognition
butterfly-dl austrailia
# Error: Source 'austrailia' not found. Did you mean 'australia-oceania'?
# Typo correction
butterfly-dl antartica
# Error: Source 'antartica' not found. Did you mean 'antarctica'?
# Geographic accuracy
butterfly-dl antartica/belgium
# Error: Source 'antartica/belgium' not found. Did you mean 'europe/belgium'?
# Standalone country recognition
butterfly-dl luxembourg
# Error: Source 'luxembourg' not found. Did you mean 'europe/luxembourg'?
# Smart continent suggestions
butterfly-dl plant
# Error: Source 'plant' not found. Did you mean 'planet'?
Features:
belgium-latest.osm.pbf)-: Stream to stdout (logs go to stderr)Connection buffers: 16 ร 64KB = 1MB
Ring buffer: 64MB (max)
HTTP client overhead: ~50MB
Runtime: ~50MB
Total: ~215MB (well under 1GB limit)
Automatically enabled for files >1GB on Unix systems:
Downloads single OpenStreetMap files efficiently:
butterfly-dl planet # Download planet file (81GB) from HTTP
butterfly-dl europe # Download Europe continent from HTTP
butterfly-dl europe/belgium # Download Belgium from HTTP
butterfly-dl europe/monaco - # Stream Monaco to stdout
Usage: butterfly-dl [OPTIONS] <SOURCE> [OUTPUT]
Arguments:
<SOURCE> Source to download: "planet" (HTTP), "europe" (continent), or "europe/belgium" (country/region)
[OUTPUT] Output file path, or "-" for stdout
Options:
--dry-run Show what would be downloaded without downloading
-v, --verbose Enable verbose logging
-h, --help Print help
-V, --version Print version
# Download planet file (uses HTTP, single stream, Direct I/O)
butterfly-dl planet
# Stream planet to compressed archive
butterfly-dl planet - | gzip > planet.pbf.gz
# Download all of Europe (parallel HTTP ranges)
butterfly-dl europe
# Download specific country
butterfly-dl europe/germany
# Download to custom location
butterfly-dl asia/japan japan-$(date +%Y%m%d).pbf
# Stream and process immediately
butterfly-dl europe/monaco - | osmium fileinfo -
# Compress on the fly
butterfly-dl europe/switzerland - | bzip2 > switzerland.pbf.bz2
# Chain with other tools
butterfly-dl planet - | osmium extract --bbox 2.3,46.8,2.4,46.9 -o monaco-bbox.pbf -
cargo build --release
# Run all tests
cargo test
# Run with verbose output
cargo test -- --nocapture
# Test with small file
time butterfly-dl europe/monaco
# Test streaming
butterfly-dl europe/monaco - | wc -c
The project uses a centralized version management system to maintain consistency across all components:
๐ Single Source of Truth:
VERSION file contains the current version number (e.g., 1.0.0)๐ง Automatic Version Propagation:
env!("BUTTERFLY_VERSION") from build script๐ Build Integration:
build.rs reads VERSION file and sets environment variablesVERSION triggers automatic rebuild๐ Updating Version:
# Update version for new release
echo "1.1.0" > VERSION
# Rebuild automatically picks up new version
cargo build --release
# All components now use 1.1.0
./target/release/butterfly-dl --version # Shows 1.1.0
Note: Cargo.toml version must still be updated manually due to Cargo limitations.
butterfly-dl includes comprehensive benchmarking against industry-standard tools to validate performance claims:
# Run benchmarks against curl and aria2
./benchmarks/bench.sh europe/monaco # Small file (~1MB)
./benchmarks/bench.sh europe/belgium # Medium file (~43MB)
./benchmarks/bench.sh europe/france # Large file (~3.5GB)
All benchmarks conducted on actual hardware over real network conditions
Tool Duration(s) Speed(MB/s) Memory Status
----------------------------------------------------------
curl 0.459 1.32 ~10MB โ
Success
butterfly-dl 0.612 0.99 ~215MB โ
Success
aria2 0.643 0.94 ~50MB โ
Success
For very small files, curl's lightweight design provides startup advantages
Tool Duration(s) Speed(MB/s) Memory Status
----------------------------------------------------------
butterfly-dl 3.037 14.07 ~215MB โ
Success
aria2 5.447 7.84 ~120MB โ
Success
curl 9.349 4.57 ~10MB โ
Success
butterfly-dl excels with 3x faster than curl and 79% faster than aria2
# Clone and build
git clone https://github.com/butterfly-osm/butterfly-osm
cd butterfly-osm
cargo build --release
# Test with any supported region
./benchmarks/bench.sh <region>
# Examples covering different file sizes
./benchmarks/bench.sh europe/monaco # Small: ~1MB
./benchmarks/bench.sh europe/luxembourg # Small: ~2MB
./benchmarks/bench.sh europe/belgium # Medium: ~43MB
./benchmarks/bench.sh europe/netherlands # Large: ~580MB
./benchmarks/bench.sh europe/france # Large: ~3.5GB
| Tool | Memory Usage | Parallel Downloads | HTTP Features | Streaming | Speed (43MB file) |
|---|---|---|---|---|---|
butterfly-dl |
~215MB | Yes (Smart) | Advanced | Yes | 14.07 MB/s |
aria2c |
~50-500MB+ | Yes | Basic | Limited | 7.84 MB/s |
curl |
~10MB | No | Basic | Yes | 4.57 MB/s |
wget |
~10MB | No | Basic | No | ~4 MB/s |
MIT License - see LICENSE file for details.
This project follows XP pair programming with human + AI collaboration. See CLAUDE.md for development guidelines.
Butterfly Project built by Pierre pierre@warnier.net for the broader OpenStreetMap community.
Butterfly-dl: The optimal tool for downloading large OpenStreetMap datasets efficiently.