Convert¶
Tippecanoe¶
Tippecanoe creates vector tiles from
GeoJSON and FlatGeobuf files, among others. As of version
2.17, Tippecanoe also supports PMTiles with the option -o
FILENAME.pmtiles
. To merge several PMTiles files into a single file, you can
use tile-join, which
comes with Tippecanoe.
Installation¶
$ sudo apt-get install gcc g++ git make libsqlite3-dev zlib1g-dev
$ git clone https://github.com/felt/tippecanoe.git
$ cd tippecanoe
$ make -j
$ make install
$ brew install tippecanoe
pmtiles CLI¶
The command line tool pmtiles
converts MBTiles
into PMTiles with the command pmtiles convert INPUT.mbtiles
OUTPUT.pmtiles
.
Installation¶
$ uv add pmtiles
rio-pmtiles¶
rio-pmtiles is a plugin for Rasterio that can be used to convert small and medium-sized raster data (~1GB).
Installation¶
$ uv add rio-pmtiles
GDAL¶
GDAL supports PMTiles from version 3.8.0. With
ogr2ogr
, a wide range of formats can be converted into PMTiles, for example
shapefiles and
PostGIS tables:
$ ogr2ogr -dsco MINZOOM=10 -dsco MAXZOOM=15 -f "PMTiles" FILENAME.pmtiles MY_SHAPES.shp
$ ogr2ogr -dsco MINZOOM=0 -dsco MAXZOOM=15 -f "PMTiles" FILENAME.pmtiles "PG:host=MY_HOST port=MY_PORT dbname=MY_DATABASE user=MY_USERNAME password=MY_PASSWORD schemas=MY_SCHEMA"
Tip
ogr2ogr
for creating vector PMTiles is only recommended for smaller data
sets: Tippecanoe generates overview tiles much more efficiently.
See also
Installation¶
$ sudo apt install libgdal20
The Apache Arrow library of the current homebrew distribution is defective. To build GDAL successfully, configure CMake so that the Arrow package is not found. Also, Boost is no longer bundled with libkml, so libkml should be disabled when building under macOS:
$ cmake -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON ..
$ cmake -DGDAL_USE_LIBKML=OFF ..
$ brew install gdal
protomaps/basemaps¶
The Protomaps basemap is based on OpenStreetMap- and Natural Earth data. It does not include all of OSM’s data and tags; instead, it is designed to provide a balance between tile size and completeness to be used as a general context map.
The organisation of layers and tags is derived from the open source project Tilezen. The amount of content and selection of data included at certain zoom levels is reflected in the reference implementations of Tilezen styles such as Bubble Wrap.
See also
The basemaps repository in tiles contains a Planetiler profile for generating planetary-level PMTiles from OpenStreetMap. The layers in this tileset are documented in Basemap Layers and daily builds can be downloaded for free from maps.protomaps.com/builds.
The pipeline for generating this daily basemap is open source and based on the Planetiler Java Tiling Engine. It can be run for your local city or country in a matter of minutes.
The advantages of a self-generated basemap include
- Up-to-date basemaps
Create tiles from specific OpenStreetMap snapshots, for example from the latest data from SliceOSM.
- Extracts
Create customised, focused area maps. Extracting an area from the daily planetary map contains additional data in tiles with a low zoom factor, as shown in the image below:
Base map of Berlin-Reinickendorf¶
You need a Java runtime environment ≥21 and Maven:
$ apt-install openjdk-21-jdk maven
$ brew install openjdk maven
An OpenStreetMap section that covers your area of interest, for example an on-demand download from SliceOSM or a pre-generated download from Geofabrik Downloads.
The district boundaries of Berlin as a GeoJSON file, downloaded from ODIS or from Who’s On First Spelunker.
Check out the basemaps project and build the JAR file:
$ git clone https://github.com/protomaps/basemaps $ cd basemaps/tiles $ mvn clean package
Create your tiles:
$ java -jar target/protomaps-basemap-HEAD-with-deps.jar --clip='~/reinickendorf.geojson' --area=reinickendorf --download
Resources such as pre-processed OSM water and land polygons, Natural Earth and data sets for language support and ranking are also downloaded.
Finally, you can display the new map by dragging the
REGION.pntiles
file into the Basemaps Viewer.
You can build a customised map of the entire planet with for example:
$ java -Xmx20g -jar target/protomaps-basemap-HEAD-with-deps.jar --nodemap-type=array --osm_path=~/planet-latest.osm.pbf --output=/data/planet.pmtiles --bounds=planet --tmpdir=/var/scratch
-Xmx20g
Provide 20 GB of heap space to the Java runtime environment.
--nodemap-type=array
A build option that is best suited for creating planet tiles.
--tmpdir=/var/scratch
Be sure to have at least 512 GB of scratch space.
Tip
For a calculation in less than three hours, we recommend as many CPU cores as possible on an Intel Core i9, AMD Ryzen 9 or similar, 64 GB RAM and at least 1 TB NVMe SSD storage.
- Custom tags
You can use the
extra_name_tags
option to add additional tags from OpenStreetMap to the output file.
Tilemaker¶
Tilemaker is a programme for creating basemap tiles from OpenStreetMap, but not ones that match the Basemap Layers of Protomaps. In addition, the PMTiles archives generated by Tilemaker are not clustered, which can lead to large, slow retrievals when decoding in a web browser. For production use, you should therefore optimise the archive with pmtiles cluster.