A high-performance, command-line tool for converting GRIB2 weather data files into map tiles that can be used with web mapping libraries like Leaflet, OpenLayers, or MapLibre.
- Converts GRIB2 weather data to MBTiles format
- Fast, parallel rendering with multiple worker threads
- High-quality WebP image encoding
- Customizable color maps for different weather parameters
- Control over zoom levels and geographic bounds
- Interpolation for smooth rendering at all zoom levels
- Built in Go for performance and portability
- Go 1.16 or later
- ecCodes library (for GRIB2 file parsing)
# Install ecCodes library
# On Ubuntu/Debian:
sudo apt-get install libeccodes-dev
# On macOS with Homebrew:
brew install eccodes
git clone https://github.com/hstin-de/grib2tiles.git
cd grib2tiles
go build
Basic usage:
./grib2tiles input.grib2 output.mbtiles
With options:
./grib2tiles -zoom 0-10 -colors ./colors/t_2m.txt -workers 8 input.grib2 output.mbtiles
Options:
-zoom string
Zoom levels to render (MIN-MAX) (default "0-7")
-colors string
Color map file for visualization (default "colors.txt")
-area string
Bounding box (minLon,minLat,maxLon,maxLat)
-workers int
Number of parallel workers (default: all available CPUs)
-quality int
WebP quality (1-100) (default 90)
-verbose
Show detailed progress
-help
Show help
Color maps are defined in simple text files with the following format:
# Comments start with #
# Format: threshold R G B A
-inf 13 26 43 255 # Values below the first threshold
0.1 32 58 96 255 # Values >= 0.1
10.0 240 184 0 255 # Values >= 10.0
Each line specifies a threshold value and an RGBA color. Values greater than or equal to the threshold will use that color.
Convert a temperature GRIB file to MBTiles with zoom levels 0-8:
./grib2tiles -zoom 0-8 -colors colors/t_2m.txt t_2m.grib2 t_2m.mbtiles
Convert a specific region with higher quality:
./grib2tiles -zoom 3-12 -area -10,35,30,60 -quality 95 europe.grib2 europe.mbtiles
MBTiles files can be served using various tools:
Or you can extract the tiles using tools like mbutil.
MIT License