{"id":13557377,"url":"https://github.com/openmaptiles/openmaptiles-tools","last_synced_at":"2025-05-14T22:09:23.403Z","repository":{"id":13750111,"uuid":"71543870","full_name":"openmaptiles/openmaptiles-tools","owner":"openmaptiles","description":"Tools to turn the schema into other formats","archived":false,"fork":false,"pushed_at":"2025-01-04T14:07:27.000Z","size":1644,"stargazers_count":425,"open_issues_count":37,"forks_count":138,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-05-10T01:49:51.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openmaptiles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-21T08:05:29.000Z","updated_at":"2025-05-08T23:54:13.000Z","dependencies_parsed_at":"2023-02-11T15:30:46.126Z","dependency_job_id":"bad7aba2-685c-4e7e-82f8-dd5d55d808f0","html_url":"https://github.com/openmaptiles/openmaptiles-tools","commit_stats":{"total_commits":686,"total_committers":58,"mean_commits":"11.827586206896552","dds":0.7113702623906706,"last_synced_commit":"fd57655d2a1e1dc7d4f4a6672f088290a7efa2f0"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openmaptiles%2Fopenmaptiles-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openmaptiles%2Fopenmaptiles-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openmaptiles%2Fopenmaptiles-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openmaptiles%2Fopenmaptiles-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openmaptiles","download_url":"https://codeload.github.com/openmaptiles/openmaptiles-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:04:18.766Z","updated_at":"2025-05-14T22:09:18.387Z","avatar_url":"https://github.com/openmaptiles.png","language":"Python","funding_links":[],"categories":["Python","others"],"sub_categories":[],"readme":"# OpenMapTiles Tools ![Build and publish to Docker](https://github.com/openmaptiles/openmaptiles-tools/workflows/Build%20and%20publish%20to%20Docker/badge.svg)\n\nThe OpenMapTiles toolbox for generating map vector tiles.\nIt includes tools to prepare Imposm mappings and SQL files based on layers defined in [OpenMapTiles](https://github.com/openmaptiles/openmaptiles) or similar projects. It also includes map data downloading, parsing, debugging, and performance evaluation tools.\nWe encourage other people to use this for their vector tile projects as well since this approach works well for us.\n\n## Docker Images\nThe repository hosts the code for the following Docker images. They can be built using `make build-all-dockers`.\n##### openmaptiles-tools [![](https://img.shields.io/docker/pulls/openmaptiles/openmaptiles-tools?label=downloads)](https://hub.docker.com/r/openmaptiles/openmaptiles-tools) [![](https://img.shields.io/docker/stars/openmaptiles/openmaptiles-tools?label=stars)](https://hub.docker.com/r/openmaptiles/openmaptiles-tools)\nA collection of tools for downloading, parsing, and generating map tiles described below.\n\n##### import-data [![](https://img.shields.io/docker/pulls/openmaptiles/import-data?label=downloads)](https://hub.docker.com/r/openmaptiles/import-data) [![](https://img.shields.io/docker/stars/openmaptiles/import-data?label=stars)](https://hub.docker.com/r/openmaptiles/import-data)\nMultiple data sources packaged for import into PostgreSQL DB, includes data from [Natural Earth](http://www.naturalearthdata.com/), [water polygons](http://osmdata.openstreetmap.de), and [lake centerlines](https://github.com/openmaptiles/osm-lakelines).\n\n##### postgis [![](https://img.shields.io/docker/pulls/openmaptiles/postgis?label=downloads)](https://hub.docker.com/r/openmaptiles/postgis) [![](https://img.shields.io/docker/stars/openmaptiles/postgis?label=stars)](https://hub.docker.com/r/openmaptiles/postgis)\nAn image with PostgreSQL database, PostGIS, and several other extensions, custom built for OpenMapTiles project.\n\n##### postgis-preloaded [![](https://img.shields.io/docker/pulls/openmaptiles/postgis-preloaded?label=downloads)](https://hub.docker.com/r/openmaptiles/postgis-preloaded) [![](https://img.shields.io/docker/stars/openmaptiles/postgis-preloaded?label=stars)](https://hub.docker.com/r/openmaptiles/postgis-preloaded)\nThe above `postgis` image pre-loaded with the `import-data`. This image is mostly used for testing, and may not be appropriate for production. The image has hardcoded user `openmaptiles` and password `openmaptiles`.\n\n\n##### generate-vectortiles [![](https://img.shields.io/docker/pulls/openmaptiles/generate-vectortiles?label=downloads)](https://hub.docker.com/r/openmaptiles/generate-vectortiles) [![](https://img.shields.io/docker/stars/openmaptiles/generate-vectortiles?label=stars)](https://hub.docker.com/r/openmaptiles/generate-vectortiles)\nLegacy Mapnik-based image that simplifies `tilelive-copy` tile generation. Mapnik is outdated and is not actively maintained. Instead, use `generate-tiles` script from the openmaptiles-tools docker image.\n\n## Additional Documentation\n\nSee [/docs](./docs)\n\n## Usage\n\nYou need either just Docker or Python 3 installed on your system. You also need Docker-compose for testing. If running without Docker, see below for the list of additional tools and libraries.\n\n#### Usage with Docker\n\nThe easiest is to use docker directly to run this command. You do not need to clone `openmaptiles-tools` locally, just clone the [openmaptiles repo](https://github.com/openmaptiles/openmaptiles) and run from its root.\n\n_**Note:** container scripts can only access files from the given directory and below, e.g. in this example - `${PWD}` - current dir._\n```bash\ndocker run -it --rm -u $(id -u ${USER}):$(id -g ${USER}) \\\n           -v \"${PWD}:/tileset\" \\\n           openmaptiles/openmaptiles-tools \\\n           \u003cscript-name\u003e \u003cscript-parameters\u003e\n```\n\nWhere the `\u003cscript-name\u003e` could be any of the scripts in the [bin/](./bin) directory, e.g. `generate-imposm3 openmaptiles.yaml`.\n\n##### Docker Volumes\n - Mount your PBFs into the `/import` folder\n - Mount your `mapping.yaml` into the `/mapping` folder\n - If you want to use diff mode mount a persistent location to the `/cache` folder for later reuse\n\n\n#### Using without Docker\n\n```bash\n# Some tool require these packages. On Debian/Ubuntu you can install them with\nsudo apt install graphviz sqlite3 aria2 osmctools\n\n# install the package directly from git\npython3 -m pip install git+https://github.com/openmaptiles/openmaptiles-tools\n\n# Run the script you want, e.g. from the openmaptiles dir:\ngenerate-imposm3 openmaptiles.yaml\n\n# If the script doesn't run, make sure your PATH includes default PIP bin directory.\n# On Debian/Ubuntu that would be  ~/.local/bin/  (under your home dir).\n# Otherwise just run it with  ~/.local/bin/generate-imposm3 ...\n```\n\n#### Running from source\n\nMake sure you have all dependencies from the [Usage](#Usage) section above. You should have the latest Python (3.6+)\n```bash\n# Get OpenMapTiles layer data\ngit clone https://github.com/openmaptiles/openmaptiles.git\n# Get the tools repo\ngit clone https://github.com/openmaptiles/openmaptiles-tools.git\n# Run scripts from the root of the tools repository\ncd openmaptiles-tools\n# Install required dependencies (might need to run with sudo\npython3.6 -m pip install -r requirements.txt\n# The PYTHONPATH=$PWD allows script to find its modules located in the current dir.\nPYTHONPATH=$PWD python3 bin/generate-imposm3 ../openmaptiles/openmaptiles.yaml\n```\n\n#### Tools Development\n\nUse `make test` to run all of the tests locally. The Makefile will build a docker image with all the code, run all tests, and compare the build result with the files in the [testdata/expected](./testdata/expected) dir.\n\nRun `make rebuild-expected` after you modify the output produced by the generation scripts. This will re-create the expected test results to match the actual ones, and make sure the changes are what you want.\n\n## Data Concepts\n\nYou 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.\n\n\n### Define your own Layer\n\nTake a look or copy a standard layer like [building](https://github.com/openmaptiles/openmaptiles/tree/master/layers/building) to get started with your own layer.\nA layer consists out of a **Layer** definition written in YAML format.\n\nThere you specify the `layer` properties like `id`, `buffer_size` and possible Markdown documentation (`description` and `fields`).\nYou can also reference SQL files in `schema` for writing the necessary queries for your layer or create generalized tables.\nWe encourage you to have a function per layer which takes the bounding box and zoom level. This makes it easy\nto test and reuse.\n\nIf your data is based of OSM you can also directly\nreference a [imposm3 mapping file](https://imposm.org/docs/imposm3/latest/mapping.html) to choose the OSM data you need.\n\n```yaml\nlayer:\n  id: \"building\"\n  description: Buildings from OpenStreetMap\n  buffer_size: 4\n  datasource:\n    query: (SELECT geometry, render_height, class FROM layer_building(!bbox!, z(!scale_denominator!))) AS t\n  fields:\n    render_height: An approximated height from levels and height of building.\n    class:\n      description: Defines a subclass of a building (one of the known values).\n      # Values can be either a list of strings, or a dictionary\n      # Dictionary defines mapping of OSM values to the OMT field value\n      values:\n        school:\n          # subclass IN ('school','kindergarten') OR subclass LIKE 'uni%'\n          subclass: ['school','kindergarten','uni%']\n        railway:\n          # (subclass='station' AND mapping_key='railway')\n          # OR subclass in ('halt','tram_stop','subway')\n          - __AND__:\n              subclass: 'station'\n              mapping_key: 'railway'\n          - subclass: ['halt', 'tram_stop', 'subway']\nschema:\n  - ./building.sql\ndatasources:\n  - type: imposm3\n    mapping_file: ./mapping.yaml\n```\n\nFor the well known values (enums), the `fields` section can also contain the mapping of the input (OSM) values.\n\nIf a layer SQL files contains `%%FIELD_MAPPING: class%%`, `generate-sql` script will replace it\n\n```sql\nSELECT CASE\n    %%FIELD_MAPPING: class%%\nEND, ...\n```\ninto\n```sql\nSELECT CASE\n    WHEN \"subclass\" IN ('school', 'kindergarten')\n        OR \"subclass\" LIKE 'uni%' THEN 'school'\n    WHEN (\"subclass\" = 'station' AND \"mapping_key\" = 'railway')\n        OR \"subclass\" in ('halt','tram_stop','subway') THEN 'railway'\nEND, ...\n```\n\n### Define your own Tileset\n\nA **Tileset** defines which layer will be in your vector tile set (`layers`)\nand metadata used for generating a TM2Source project to actually generate the vector tiles.\n\n```yaml\ntileset:\n  layers:\n    - layers/building/building.yaml\n    - layers/housenumber/housenumber.yaml\n    - layers/poi/poi.yaml\n  name: Street Level\n  description: A tileset showing street level info like building, housenumbers and POIs.\n  attribution: \"OpenStreetMap contributors\"\n  maxzoom: 14\n  minzoom: 13\n  center: [-12.2168, 28.6135, 4]\n  bounds: [-180.0,-85.0511,180.0,85.0511]\n  pixel_scale: 256\n  defaults:\n    srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over\n    datasource:\n      srid: 900913\n```\n\n## Testing tiles\n### Tile size and PostgreSQL querying speed\nUse `test-perf` to evaluate tile generation performance against a PostgreSQL database.\nThis utility can test individual layers, several layers at once, as well as the whole tile.\nIt has several pre-defined testing areas to provide cross-test consistency.\nResults are printed as histogram graphs, showing tile size distribution.\nThe utility can compare current run with a previously saved one, highlighting large changes.\nIf multiple zoom levels are tested, another histogram shows per-zoom size distribution.\nRun with `--help` to see all options.\n\n```\ntest-perf \u003ctileset\u003e ...\n```\n\nJust like `postserve` below, `test-perf` requires PostgreSQL connection.\n\n![](./docs/test-perf.png)\n\n### Realtime tile server\n\nPostserve is an OpenMapTiles map vector tile test server that dynamically generates metadata and tiles\n directly from PostgreSQL database based on the tileset file definition.\n\n```\npostserve \u003ctileset\u003e ...\n```\n\nUse `postserve \u003ctileset\u003e` to start serving. Use `--help` to get the list of Postgres connection parameters.\n If you have a full planet database, you may want to use `MIN_ZOOM=6 postserve ...` to avoid accidental slow low-zoom\n tile generation.\n\n#### Postserve quickstart with docker\n* clone [openmaptiles repo](https://github.com/openmaptiles/openmaptiles) (`openmaptiles-tools` repo is not needed with docker)\n* get a PostgreSQL server running with the openmaptiles-imported OSM data, e.g. by following quickstart guide.\n* run `docker pull openmaptiles/openmaptiles-tools` to download the latest tools version\n* from inside the openmaptiles repo dir, run this command.\n(This assumes PostgreSQL is on the localhost:5432, but if it runs inside docker, you may want to change\n `--net=host` to `--net=openmaptiles_postgres` to match the openmaptiles quickstart, and also expose\n port 8090 to the host with `-p 8090:8090`)\n```\ndocker run -it --rm -u $(id -u ${USER}):$(id -g ${USER}) \\\n    -v \"${PWD}:/tileset\" --net=host \\\n    openmaptiles/openmaptiles-tools \\\n    postserve openmaptiles.yaml\n```\n\n#### Viewing dynamic tiles\nYou can view tiles with any MVT-supporting viewer, such as:\n* [Maputnik editor](https://maputnik.github.io/editor) (online) -- change the data source to `http://localhost:8090`\n* [QGIS desktop](https://www.qgis.org/en/site/) -- add `Vector Tiles Reader` plugin, and add a vector tile server connection with TileJSON URL set to `http://localhost:8090`.\n\n### Examining realtime tile content\n\nUse `debug-mvt` tool to examine tile content. The tool will query PostgreSQL server and show layers with each data row and geometry type/size.\nThis tool can limit output to just a few layers, optionally show all localized names, and show geometries as text. This example queries shows entries in the \"place\" layer for the specified tile:\n\n```bash\n$ debug-mvt openmaptiles.yaml 4/7/6 -l place\n======= Layer place (extra name columns are hidden by default) =======\n  capital  class    iso_a2    name                        name_de                     name_en                       rank       osm_id  is_valid_mvt    mvtgeometry    is_valid_geom    geometry\n---------  -------  --------  --------------------------  --------------------------  --------------------------  ------  -----------  --------------  -------------  ---------------  ----------\n           country  ES        Espaa                       Spanien                     Spain                            1   1483323000  True            POINT(32)      True             POINT(32)\n           country  PT        Portugal                    Portugal                    Portugal                         1  23770282470  True            POINT(32)      True             POINT(32)\n        4  city               Casablanca                  Casablanca                  Casablanca                       2    257307240  True            POINT(32)      True             POINT(32)\n           country  MA        Maroc                       Marokko                     Morocco                          2   4324250410  True            POINT(32)      True             POINT(32)\n        2  city               Madrid                      Madrid                      Madrid                           2    210682950  True            POINT(32)      True             POINT(32)\n        2  city               Lisboa                      Lissabon                    Lisbon                           3   2659584900  True            POINT(32)      True             POINT(32)\n        4  city               Oran                        Oran                        Oran                             4    275651030  True            POINT(32)      True             POINT(32)\n        4  city               Valncia                     Valencia                    Valencia                         4    341056070  True            POINT(32)      True             POINT(32)\n        4  city               Sevilla                     Sevilla                     Seville                          4   2488206560  True            POINT(32)      True             POINT(32)\n        4  city               Fs                          Fs                          Fez                              4   2890354320  True            POINT(32)      True             POINT(32)\n        2  city               Rabat                       Rabat                       Rabat                            4   2991208620  True            POINT(32)      True             POINT(32)\n        ...\n```\n\n### Profile PostgreSQL functions\nUse `profile-pg-func` to compare PostgreSQL function execution speed. Each function is called thousands of times in several runs. The fastest and slowest runs are discarded. `profile-pg-func` can import SQL files before running the test, e.g. to add the latest developer versions of the function(s).\n\n### Show layer statistics for a field\nUse `layer-stats` show per zoom statistics for some column (field) in a single layer. Supports several metrics:\n* `frequency` - Shows how often each unique value occurs in a layer's column or combination of columns.\n* `toplength` - Shows the longest N values for a given layer's column.\n* `variance` - Shows a few statistical metrics for a column's numeric value.\n\n## Tools\n\n### Environment variables\nVarious tools require these environment variables to be set\n\n* `SQL_DIR`             /sql\n* `PBF_DATA_DIR`        /import\n* `IMPOSM_CACHE_DIR`    /cache\n* `IMPOSM_MAPPING_FILE` /mapping/mapping.yaml\n* `IMPOSM_DIFF_DIR`     /import\n\n* `EXPIRETILES_DIR` used by `import-update` for Imposm's `-expiretiles-dir` parameter\n* `EXPIRETILES_ZOOM` defaults to 14\n\n### Multi-streamed OSM Data Downloader\n`download-osm` tool can be used to download an area extract or the entire planet file,\nand validate file content. The entire planet file is downloaded from all available\nOSM mirrors at the same time to distribute the load across mirrors, and makes download faster.\nThe tool will ensure you get the latest version, verifies that all mirrors contain the same\nversion, and validates the download with md5 hash. By default the tool will not download from\nthe primary OSM site to reduce its load. Downloader uses [aria2c](https://aria2.github.io/).\nDownloader can also get files from [Geofabrik](https://download.geofabrik.de/),\n[BBBike](https://download.bbbike.org/osm/), and\n[openstreemap.fr](https://download.openstreetmap.fr/extracts), or an arbitrary URL.\n\n```bash\n# downloads the latest version to the current directory\ndownload-osm planet\n\n# download to the target dir by passing -d ... param to aria2c\ndownload-osm planet -- -d ./downloads\n\n# download New Zealand extract from Geofabrik, together with the state file\ndownload-osm geofabrik new-zealand --state state.txt\n\n# List all extracts available from Geofabrik\ndownload-osm list geofabrik\n```\n\n### Generate SQL to create MVT tiles with PostGIS ST_AsMVT function\n\nUses tileset definition to create a PostgreSQL\n [prepared](https://www.postgresql.org/docs/current/sql-prepare.html) or\n [create function](https://www.postgresql.org/docs/14/sql-createfunction.html) SQL code\n to generate an entire vector tile in the Mapbox Vector Tile format with a single `getTile(z,x,y)` query\n using PostGIS MVT support.\n\nUse `--help` to get all parameters.\n\n**NOTE:** Known bug is PostgreSQL JIT could make tile generation horribly slow in PG11+, and may need to be disabled.\n\n```\ngenerate-sqltomvt \u003ctileset\u003e\n```\n\n### Generate Imposm3 Mapping File\n\nGenerate Imposm3 mapping file to import OSM data using a tileset definition file.\n\n```\ngenerate-imposm3 \u003ctileset\u003e\n```\n\n### Generate SQL scripts\n\nAssembles all SQL referenced in the layer definitions into an SQL script that can be executed with psql.\nIf `--dir` option is given, generates `.sql` files that can be executed in parallel.\n\n```\ngenerate-sql \u003ctileset\u003e\ngenerate-sql \u003ctileset\u003e --dir \u003coutputdir\u003e\n```\n\n### Generate Markdown Documentation\n\nTakes a tileset definition and generates Markdown documentation.\n\n```\ngenerate-doc \u003ctileset\u003e\n```\n\n### Generate MBTiles tile snapshot file\n\n`generate-tiles` script generate tiles from PostgreSQL using [tilelive-copy](https://github.com/mapbox/tilelive#bintilelive-copy) with [tilelive-pgquery](https://github.com/nyurik/tilelive-pgquery#tilelive-pgquery).\nIf run with `LIST_FILE` environment variable, this script will only generate tiles given in the list file, and it will ignore min/mid/max zoom values. For example, set `LIST_FILE=/export/tiles.txt` to match what was previously done with `export-list.sh` script.\n\nIf the `LIST_FILE` and `MID_ZOOM` environment variables are not set, this script will generate all tiles from `MIN_ZOOM` to `MAX_ZOOM` (inclusive).\n\nIf `MID_ZOOM` env var is set, `generate-tiles` will first generate all tiles from `MIN_ZOOM` to `MID_ZOOM`. Afterwards, `mbtiles-tools impute` finds the most duplicated small tiles at `MID_ZOOM`, and treats them as \"empty\" -- it copies empty tiles to the next `MID_ZOOM+1` level as is, without regenerating them. The non-empty tiles at `MID_ZOOM+1` are then generated as before using a list of tiles generated by the `impute` command. Once done, the same steps are repeated for `MID_ZOOM+2`, etc., until the `MAX_ZOOM` (inclusive).\n\nLastly, `generate-tiles` runs `mbtiles-tools meta-generate` to update mbtiles metadata unless `TILESET_FILE` is not set.\n\n`generate-tiles` script does not take any parameters, but accepts many environment variables -- see [code](bin/generate-tiles).\n\n### Generate ETL (Extract-Transform-Load) graph\n\ndependency: graphviz\n\nTakes a source code from the imposm3 mapping file and the SQL postprocessing code,\nand parsing for the `etldoc:` graphviz based comments, and generate an svg file.\nThe `.dot` and the `.svg` filename prefix is `etl_`\n\n```\ngenerate-etlgraph \u003ctileset\u003e \u003ctarget-directory\u003e\ngenerate-etlgraph layers/landcover/landcover.yaml  ./build/devdoc\ngenerate-etlgraph layers/railway/railway.yaml      ./build/etlgraph\n```\n\nexample:\n\ninput command: `generate-etlgraph layers/landcover/landcover.yaml`\noutput fies:\n- `layers/landcover/etl_landcover.dot`\n- `layers/landcover/etl_landcover.svg`\n\n\n### Generate SQL query for a given layer and zoom level\n\nexample:\n```\ngenerate-sqlquery layers/landcover/landcover.yaml 14\n```\n\n### Import and Update OSM data\nThe `import-osm`, `import-update`, and `import-diff` tools will import and update\nPostgreSQL database by running [imposm](https://imposm.org/docs/imposm3/latest/).\nThe tools expect these env vars: `PGHOST`, `PGDATABASE`, `PGUSER`, `PGPASSWORD`, and optionally `PGPORT`\nto connect to the PostgreSQL server, and a number of other vars for imposm configuration. See scripts.\n\n\n### Import Wikidata localized names\nThe `import-wikidata` tool searches for all wikidata tags in the database,\nand uses Wikidata Query Service to get the labels in all languages.\nThis tool looks at all tables defined in layers' mapping files if they contain\n`tags` hstore field, and if the table has no `_resolve_wikidata: false` flag.\nThe localized names are written to the `wd_names` table, which will be created if missing.\n\n```bash\nimport-wikidata openmaptiles.yaml\n```\n\n### Mbtiles file tools\nThis command allows users to examine and manipulate mbtiles file:\n* generate metadata based on the layers definition\n* get, set, and delete individual metadata values\n* validate and print all metadata values and mbtiles file statistics\n* list all tile keys (hashes) that are used many times (usually indicates empty tiles)\n* copy zooms, e.g. copy all empty tiles z13 to z14, and create a list of all tiles that needs to be generated.\n```\nmbtiles-tools --help\nmbtiles-tools ./data/tiles.mbtiles meta-all\n```\n\n### Generate TM2Source Projects for Mapbox Studio Classic\n\nTakes a tileset definition and generates a TM2Source YAML project file.\nYou need to provide PostgreSQL database connection settings before generating the project.\n\n```\ngenerate-tm2source \u003ctileset\u003e --host=\"localhost\" --port=5432 --database=\"osm\" --user=\"osm\" --password=\"osm\"\n```\n\n### Import OSM Borders\n\nThe **import-borders** script will take the first PBF file from the `/import` dir (by default), extract borders with [osmborder tool](https://github.com/pnorman/osmborder), and import resulting CSV file into the database as osm_border_linestring table (by default). Example usages:\n\n```bash\nimport-borders                      # Parse and import first PBF file in PBF_DATA_DIR\nimport-borders [import] planet.pbf  # Parse and import planet.pbf\nimport-borders parse planet.pbf     # Parse planet.pbf into a CSV file, but do not import\nimport-borders load borders.csv     # Load borders.csv into a table\n```\n\nThis utility requires PostgreSQL's PG* environment variables, and optionally uses `PBF_DATA_DIR, BORDERS_PBF_FILE, BORDERS_CSV_FILE, BORDERS_TABLE_NAME`.\n\n## Importing into Postgres\nThe `import-sql` script can execute a single SQL file in Postgres when the file is given as the first parameter.\n\nIf ran without any arguments, `import-sql` executes all of the following:\n* SQL files from `$SQL_TOOLS_DIR` - contains all SQL files to be imported before the ones generated by OpenMapTiles project. By default, contains OMT fork of the Mapbox's [postgis-vt-util.sql](https://github.com/openmaptiles/postgis-vt-util) helper functions and contains the [sql/language.sql](sql/zzz_language.sql) script. (as `10_postgis-vt-util.sql` - the file name has to be imported before files in `/sql`)\n* SQL files from `$SQL_DIR` - defaults to `/sql` -- this directory should contain the results of the `generate-sql --dir ...` script and possibly other user-defined sql scripts. If this directory contains `parallel/` subdirectory, `import-sql` will assume the parallel/*.sql files are safe to execute in parallel, up to `MAX_PARALLEL_PSQL` at a time (defaults to 5). The script will also execute `run_first.sql` before, and `run_last.sql` after the files in `parallel/` dir (if they exist).\n\nGenerating and importing SQL could be done in a single step with `\u0026\u0026`, e.g.\n\n```bash\ngenerate-sqltomvt openmaptiles.yaml \u003e \"$SQL_DIR/mvt.sql\" \u0026\u0026 import-sql\n```\n\nOptionally you may pass extra arguments to `psql` by using `PSQL_OPTIONS` environment variable. For example `PSQL_OPTIONS=-a` makes psql echo all commands read from a file into stdout.\n`PSQL_OPTIONS` allows multiple arguments as well, and understands quotes, e.g. you can pass a whole query as a single argument surrounded by quotes -- `PSQL_OPTIONS=\"-a -c 'SELECT ...'\"`\n\n### Environment variables\nMost PostgreSQL-related images support standard PostgreSQL environment variables like `PGUSER`, `PGPASSWORD`, `PGHOST`, `PGDATABASE`, and optionally `PGPORT`.\n\nThe only exception is the [`postgis`](./docker/postgis) image, which uses [different variables](https://hub.docker.com/_/postgres/) (`POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_HOST`, `POSTGRES_DB`, `POSTGRES_PORT`) during database creation due to how the official Docker postgres image has been set up.\n\n\n### Performance optimizations\nMaterialized views can be refreshed in parallel using `refresh-views` command. This could be especially useful if the `CREATE MATERIALIZED VIEW` statements had `WITH NO DATA` clause.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmaptiles%2Fopenmaptiles-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenmaptiles%2Fopenmaptiles-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmaptiles%2Fopenmaptiles-tools/lists"}