Generating Vector Tiles using the Docker Containers for macOS

In this lesson we will learn to use Docker containers to create and serve vector tiles on your Macintosh laptop.

1. Install Docker on macOS

  • Download Docker Community Edition for Mac
  • Mount Docker.dmg
  • Drag Docker App onto Applications Shortcut
  • Launch Docker (double-click Docker Icon)
  • Agree to run application from Internet
  • Supply admin password when prompted

2. Install a GDAL/OGR tools container

  • Go to Docker Hub
  • Search for gdal
  • Select klokantech/gdal
  • Copy the Docker Pull Command & run it at the Terminal prompt

    docker pull klokantech/gdal

3. Convert shape file into GeoJSON file

  • Download zipped files of King County Census Blocks
  • Place zip file into your local directory
  • Unzip zip file
  • Use OGR tools at the Terminal prompt
    • ogrinfo: check the shape file’s information

      docker run -ti --rm -v $(pwd):/data klokantech/gdal ogrinfo KingCo_2000_Census_BlockGroups.shp -al -so

    • ogr2ogr: convert shape file to GeoJSON file

      docker run -ti --rm -v $(pwd):/data klokantech/gdal ogr2ogr -t_srs EPSG:4326 -f GeoJSON KingCo_2000_Census_BlockGroups.geojson KingCo_2000_Census_BlockGroups.shp -Progress

4. Locate a geoJSON file

5. Install a Tippecanoe container which is a utility tool to create vector tiles

  • Search for Tippecanoe on Docker Hub
  • Select the jskeates/tippecanoe repository
  • Copy the appropriate command from the Docker Pull Command section of the page
  • Paste it at the Terminal prompt, and hit enter to run it

    docker pull jskeates/tippecanoe

6. Create some vector tiles

  • Ensure Docker is running on your computer
  • Start Tippecanoe container in interactive mode at the Terminal prompt

    docker run -it -v $(pwd):/home/tippecanoe jskeates/tippecanoe:latest

  • You will see your command prompt change to look like bash-4.3$
  • Use the tippecanoe command at the Terminal prompt to create vector tiles from the geoJSON file

    tippecanoe -o KingCo_2000_Census_BlockGroups.mbtiles KingCo_2000_Census_BlockGroups.geojson

  • Exit the container when it is done

    exit

  • The vector tiles will now be in your directory

7. Install a TileServer GL container

  • Go to Docker Hub
  • Search for tileserver-gl
  • Select klokantech/tileserver-gl
  • Copy the Docker pull command & run it at the Terminal prompt docker pull klokantech/tileserver-gl

8. Run TileServer GL

  • Ensure Docker is running on your computer
  • From the command line change into the directory where you have placed your mbtiles file
  • Start the TileServer GL container from the Terminal prompt

    docker run --rm -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl

  • Test that the vector tiles are being servered by entering http://localhost:8080/ into your browser’s address bar
  • After testing, hit ctl-C to quit TileServer GL