About MBTiles

MBTiles is an open specification developed by Mapbox for storing tiled map data in a single SQLite database file. It's widely used in the geospatial industry for offline mapping and mobile applications.

How to Use MBTiles

1. Serve with TileServer

Use a tile server like tileserver-gl or mbtileserver:

# Install tileserver-gl
npm install -g tileserver-gl-light

# Serve the MBTiles file
tileserver-gl-light rgb_tiles.mbtiles

2. Extract to XYZ Tiles

Convert back to individual tile files using mb-util:

# Install mb-util
pip install mbutil

# Extract tiles
mb-util rgb_tiles.mbtiles output_dir/

3. Use in Mobile Apps

Many mobile mapping SDKs support MBTiles directly:

  • Tangram ES
  • Nutiteq SDK
  • Custom implementations with SQLite

Creating MBTiles

Generate MBTiles from a raster using GDAL:

# Step 1: Generate XYZ tiles
gdal2tiles.py -z 7-14 input.tif output_dir/

# Step 2: Convert to MBTiles
mb-util output_dir/ output.mbtiles

Advantages vs XYZ Tiles

Feature MBTiles XYZ Tiles
File Count ✓ Single file ✗ Thousands
Offline Use ✓ Excellent ~ Possible
CDN Caching ~ Requires server ✓ Perfect
Distribution ✓ Easy (1 file) ✗ Complex