Skip to content

Creating PMTiles

Tippecanoe

Tippecanoe is the supported tool for converting datasets into tiles. Tippecanoe version 2.17 and later supports direct PMTiles output.

An example of how to convert a Shapefile: US Census Bureau Tabulation Areas in two steps, using GDAL's ogr2ogr command line tool:

bash
ogr2ogr -t_srs EPSG:4326 cb_2018_us_zcta510_500k.json cb_2018_us_zcta510_500k.shp
# Creates a layer in the vector tiles named "zcta"
tippecanoe -zg --projection=EPSG:4326 -o cb_2018_us_zcta510_500k_nolimit.pmtiles -l zcta cb_2018_us_zcta510_500k.json
ogr2ogr -t_srs EPSG:4326 cb_2018_us_zcta510_500k.json cb_2018_us_zcta510_500k.shp
# Creates a layer in the vector tiles named "zcta"
tippecanoe -zg --projection=EPSG:4326 -o cb_2018_us_zcta510_500k_nolimit.pmtiles -l zcta cb_2018_us_zcta510_500k.json

To merge multiple pmtiles files into a single file use tile-join tool, which is shipped with Tippecanoe

sh
# Merge all PMTiles files in current folder into single file
tile-join -o merged.pmtiles *.pmtiles
# Merge all PMTiles files in current folder into single file
tile-join -o merged.pmtiles *.pmtiles

MBTiles

the pmtiles command line tool converts MBTiles to PMTiles with this command:

pmtiles convert INPUT.mbtiles OUTPUT.pmtiles

GeoTIFF

Using a file from OSGeo's GeoTIFF samples and the rio-mbtiles Python tool:

sh
# convert single-band to 3-band RGB GeoTIFF
gdal_translate -expand rgb input.tif input_rgb.tif

# in this example create 512x512 PNG tiles from zooms 0 to 16.
rio mbtiles input_rgb.tif output.mbtiles --format PNG --zoom-levels 0..16 --tile-size 512 --resampling bilinear

pmtiles convert output.mbtiles output.pmtiles
# convert single-band to 3-band RGB GeoTIFF
gdal_translate -expand rgb input.tif input_rgb.tif

# in this example create 512x512 PNG tiles from zooms 0 to 16.
rio mbtiles input_rgb.tif output.mbtiles --format PNG --zoom-levels 0..16 --tile-size 512 --resampling bilinear

pmtiles convert output.mbtiles output.pmtiles

GDAL

GDAL has native support for PMTiles starting with version 3.8.0 (2023-11-13), see gdal.org/drivers/vector/pmtiles for details.

Using ogr2ogr to create vector PMTiles is recommended only for smaller datasets: the tippecanoe tool creates much more efficient overview tiles.

GDAL's ogr2ogr tool supports a wide range of formats as input for creating PMTiles. Below are examples of generating PMTiles from a Shapefile or multiple PostgreSQL/PostGIS tables.

sh
# Convert shapefile to to pmtiles
ogr2ogr -dsco MINZOOM=10 -dsco MAXZOOM=15 -f "PMTiles" filename.pmtiles my_shapes.shp

# Merge all PostgreSQL/PostGIS tables in a schema into a single PMTiles file.
ogr2ogr -dsco MINZOOM=0 -dsco MAXZOOM=15 -f "PMTiles" filename.pmtiles "PG:host=my_host port=my_port dbname=my_database user=my_user password=my_password schemas=my_schema"
# Convert shapefile to to pmtiles
ogr2ogr -dsco MINZOOM=10 -dsco MAXZOOM=15 -f "PMTiles" filename.pmtiles my_shapes.shp

# Merge all PostgreSQL/PostGIS tables in a schema into a single PMTiles file.
ogr2ogr -dsco MINZOOM=0 -dsco MAXZOOM=15 -f "PMTiles" filename.pmtiles "PG:host=my_host port=my_port dbname=my_database user=my_user password=my_password schemas=my_schema"
  • MAXZOOM=15 is sufficient for street-level mapping. Choosing less detail with a lower MAXZOOM will reduce the size of the final file.

Other

WARNING

This section is under construction.

An open source mapping system released under the BSD and ODbL licenses.