Package: openmaptiles-tools
OpenMapTiles ToolsThe 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 theOpenMapTiles projectfor a real world example.InstallYou need Python 2 or Python 3 installed on your system.
External dependency:  graphviz, sqlite3pipinstallopenmaptiles-tools# You can also install the package directly from gitpipinstallgit+https://github.com/openmaptiles/openmaptiles-tools# Some tool call external command,  you can install them on debian / ubuntu :apt-getinstallgraphvizsqlite3ConceptsYou define a self containedLayertogether with SQL files and layer and data source definitions (like an imposm3 mapping file) that you can then reference in aTilesetwhere you mix and match with other layers.Define your own LayerTake a look or copy a standard layer likebuildingto get started with your own layer.
A layer consists out of aLayerdefinition written in YAML format.There you specify thelayerproperties likeid,buffer_sizeand possible Markdown documentation (descriptionandfields).
You can also reference SQL files inschemafor 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 aimposm3 mapping fileto choose the OSM data you need.layer:id:"building"description:Buildings from OpenStreetMapbuffer_size:4datasource:query:(SELECT geometry FROM layer_building(!bbox!, z(!scale_denominator!))) AS tfields:render_height:An approximated height from levels and height of building.schema:-./building.sqldatasources:-type:imposm3mapping_file:./mapping.yamlDefine your own TilesetATilesetdefines 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.yamlname:Street Leveldescription:A tileset showing street level info like building, housenumbers and POIs.attribution:"OpenStreetMapcontributors"maxzoom:14minzoom:13center:[-12.2168,28.6135,4]UsageGenerate TM2Source Projects for Mapbox Studio ClassicTakes 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 FileTakes a tileset definition an generates an imposm3 mapping file for importing OSM data.generate-imposm3 <tileset>Collect SQL schemasTakes a tileset definition and collects all SQL referenced in the layer definitions.generate-sql <tileset>Generate Markdown DocumentationTakes a tileset definition and generates Markdown documentation.generate-doc <tileset>Generate ETL (Extract-Transform-Load ) graphdependency:  graphvizTakes a source code from the imposm3 mapping file and the SQL postprocessing code ,
nad parsing for theetldoc:graphviz based comments, and generate an svg file.
The.dotand the.svgfilename prefix isetl_generate-etlgraph <tileset>  <target-directory>
generate-etlgraph layers/landcover/landcover.yaml  ./build/devdoc
generate-etlgraph layers/railway/railway.yaml      ./build/etlgraphexample:input command:generate-etlgraph layers/landcover/landcover.yamloutput fies:layers/landcover/etl_landcover.dotlayers/landcover/etl_landcover.svgGenerate SQL query for a given layer and zoom levelexample:generate-sqlquery layers/landcover/landcover.yaml  14Add simple metadata to mbtiles filedependency:  sqlite3example:generate_metadata ./data/tiles.mbtiles