Skip to main content

The OpenMapTiles tools for generating TM2Source projects, imposm3 mappings and SQL instructions from OpenMapTiles layers. We encourage other people to use this for their vector tile projects as well since this approach works well for us.

Project description

OpenMapTiles Tools Build Status Docker Automated build

The OpenMapTiles tools for generating TM2Source projects, imposm3 mappings and SQL instructions from OpenMapTiles layers. We encourage other people to use this for their vector tile projects as well since this approach works well for us.

Check out the OpenMapTiles project for a real world example.

Install

You need Python 2 or Python 3 installed on your system. External dependency: graphviz, sqlite3

pip install openmaptiles-tools
# You can also install the package directly from git
pip install git+https://github.com/openmaptiles/openmaptiles-tools

# Some tool call external command,  you can install them on debian / ubuntu :
apt-get install  graphviz sqlite3 

Concepts

You define a self contained Layer together with SQL files and layer and data source definitions (like an imposm3 mapping file) that you can then reference in a Tileset where you mix and match with other layers.

Define your own Layer

Take a look or copy a standard layer like building to get started with your own layer. A layer consists out of a Layer definition written in YAML format.

There you specify the layer properties like id, buffer_size and possible Markdown documentation (description and fields). You can also reference SQL files in schema for writing the necessary queries for your layer or create generalized tables. We encourage you to have a function per layer which takes the bounding box and zoom level. This makes it easy to test and reuse.

If your data is based of OSM you can also directly reference a imposm3 mapping file to choose the OSM data you need.

layer:
  id: "building"
  description: Buildings from OpenStreetMap
  buffer_size: 4
  datasource:
    query: (SELECT geometry FROM layer_building(!bbox!, z(!scale_denominator!))) AS t
  fields:
    render_height: An approximated height from levels and height of building.
schema:
  - ./building.sql
datasources:
  - type: imposm3
    mapping_file: ./mapping.yaml

Define your own Tileset

A Tileset defines which layer will be in your vector tile set (layers) and metadata used for generating a TM2Source project to actually generate the vector tiles.

tileset:
  layers:
    - layers/building/building.yaml
    - layers/housenumber/housenumber.yaml
    - layers/poi/poi.yaml
  name: Street Level
  description: A tileset showing street level info like building, housenumbers and POIs.
  attribution: "OpenStreetMap contributors"
  maxzoom: 14
  minzoom: 13
  center: [-12.2168, 28.6135, 4]

Usage

Generate TM2Source Projects for Mapbox Studio Classic

Takes a tileset definition an generates a TM2Source YAML project file. You need to provide PostgreSQL database connection settings before generating the project.

generate-tm2source <tileset> --host="localhost" --port=5432 --database="osm" --user="osm" --password="osm"

Generate Imposm3 Mapping File

Takes a tileset definition an generates an imposm3 mapping file for importing OSM data.

generate-imposm3 <tileset>

Collect SQL schemas

Takes a tileset definition and collects all SQL referenced in the layer definitions.

generate-sql <tileset>

Generate Markdown Documentation

Takes a tileset definition and generates Markdown documentation.

generate-doc <tileset>

Generate ETL (Extract-Transform-Load ) graph

dependency: graphviz

Takes a source code from the imposm3 mapping file and the SQL postprocessing code , nad parsing for the etldoc: graphviz based comments, and generate an svg file. The .dot and the .svg filename prefix is etl_

generate-etlgraph <tileset>  <target-directory>
generate-etlgraph layers/landcover/landcover.yaml  ./build/devdoc
generate-etlgraph layers/railway/railway.yaml      ./build/etlgraph 

example:

input command: generate-etlgraph layers/landcover/landcover.yaml output fies:

  • layers/landcover/etl_landcover.dot
  • layers/landcover/etl_landcover.svg

Generate SQL query for a given layer and zoom level

example:

generate-sqlquery layers/landcover/landcover.yaml  14

Add simple metadata to mbtiles file

dependency: sqlite3

example:

generate_metadata ./data/tiles.mbtiles

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmaptiles-tools-0.9.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

openmaptiles_tools-0.9.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file openmaptiles-tools-0.9.2.tar.gz.

File metadata

  • Download URL: openmaptiles-tools-0.9.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

File hashes

Hashes for openmaptiles-tools-0.9.2.tar.gz
Algorithm Hash digest
SHA256 faa153e811ddb730af7980d4f884f11185935ae6926b87aa199c1b5380bfd15a
MD5 be6c27afc35272976611b2b9add73ab6
BLAKE2b-256 58e0e4c3776ca5c57012bbe7567f7e767a11dad5b7a5d6ed8a0f091b4c49544e

See more details on using hashes here.

File details

Details for the file openmaptiles_tools-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: openmaptiles_tools-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2

File hashes

Hashes for openmaptiles_tools-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c10809e7df7025773960f0f9c6a35710069fdfe476991af8a95cde645bce0080
MD5 439ae1e78c78f79117a4bcec160deb84
BLAKE2b-256 b5482d5ff0fbaa59d967ad2a9eb7e697100abb5fa48688e4a51d0e1ff6797c45

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page