/local-tile-craft

example for locally generating, editing, and exporting vector tiles from OpenStreetMap data

Primary LanguageLua

LocalTileCraft

This repository is a practical example of the process for locally generating, editing, and exporting vector tiles from OpenStreetMap (OSM) data.

Setup

Before diving into the repository, make sure you have the following installed:

  • go-pmtiles: Install this essential tool by executing make install-pmtiles for macOS. Alternatively, you can download and install it from the go-pmtiles releases page.
  • Docker: Docker is required to run the Maputnik editor.
  • Task Runner: We use Task as a task runner to streamline the workflow.

then run the following command to set up the environment:

task setup

Obtaining OSM Data

Fetch the osm.pbf OSM data, for example, from Geofabrik, and place it in the data/ directory. as example, you can run:

task dl-pbf

Generating mbtiles

We utilize tilemaker to generate mbtiles from the OSM data:

task make-mbtiles

To preview the generated mbtiles:

task preview-mbtiles

Converting mbtiles to pmtiles

We convert the mbtiles to pmtiles before proceeding with style editing and map image exporting, since pmtiles are easy to host locally.

task convert-pmtiles

Style Editing

For editing the map style, follow these steps:

  1. Launch the Maputnik editor:
task run-maputnik
  1. Open your preferred web browser and navigate to http://localhost:8888.
  2. Within the Maputnik UI:
    • Click on "Open."
    • Choose "Upload" and select the style JSON file located in the style/ directory.
    • Customize the style according to your preferences.

Exporting Map Image

To export the map as an image, execute:

task run-export

This command will locally serve the web app for the exporting process.