In this tutorial you will learn how to create your own vector tiles with the help of the OSM2VectorTiles toolset. In order to run through the following steps you need to have docker and docker-compose installed.
Clone the OSM2VectorTiles repository and change directory to it.
git clone https://github.com/osm2vectortiles/osm2vectortiles.git cd ./osm2vectortiles
Start up your PostGIS container with the data container attached.
docker-compose up -d postgis
wget https://s3.amazonaws.com/metro-extracts.mapzen.com/zurich_switzerland.osm.pbf -P ./import
docker-compose up import-external
With the next command the downloaded PBF file gets imported into PostGIS.
docker-compose up import-osm
The following command imports custom SQL utilities such as functions and views, which are needed to create the vector tiles.
docker-compose up import-sql
Now export a MBTiles file by passing the bounding box you want your desired extract for.
docker-compose run \ -e BBOX="8.34,47.27,8.75,47.53" \ -e MIN_ZOOM="8" \ -e MAX_ZOOM="14" \ export
Finally, the following command generates the vector tiles and creates an MBTiles file in the
docker-compose up export
In order to display your vector tiles follow the getting started tutorial.
Optional: Merge lower zoom levels (z0 to z5) into extract (prerequisite: sqlite3 installed)
Download lower zoom level extract.
wget -P ./export/ https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v2.0/planet_z0-z5.mbtiles
patch.sh script from the Mapbox mbutil project.
wget https://raw.githubusercontent.com/mapbox/mbutil/master/patch chmod +x patch
Merge lower zoom levels into extract.
./patch "./export/planet_z0-z5.mbtiles" "./export/zurich.mbtiles"