Generating and styling vector tiles in QGIS "MBStyle Generator"

Introduction

I was inspired by an article I read earlier on Qiita about hosting vector tiles on GitHub (I lost track of the URL). The content is that tiled vector data has a very small file size and is suitable for hosting by GitHub. I certainly thought. This means that anyone can deliver vector tiles. Anyone can use the data of any size, regardless of the size, just by putting it in the repository as long as it can be tiled. I thought it would be wonderful if it was realized. On the other hand, I also feel that creating vector tiles is a high hurdle (rather than being difficult, the effort of building an environment becomes a barrier), and it is vague that if the creation and distribution of vector tiles can be done easily, that situation may be realized. I had an idea. Meanwhile, as I introduced before, I found a plug-in called VectorTilesReader (hereafter VTReader). This is a plugin that loads vector data that is already tiled and hosted in QGIS. On the contrary, I thought it would be convenient if I could easily export QGIS layers as vector tiles, so I created "MBStyle Generator".

MBStyleGenerator https://github.com/Kanahiro/MBStyleGenerator https://plugins.qgis.org/plugins/MBStyleGenerator-master/

Sample sample.png

This screenshot shows the styling of several layers of the Geographical Survey Institute vector tiles loaded with VTReader on QGIS and the style.json created with MBStyleGenerator using those layers loaded with Mapbox GL JS. (Displayed with Opacity = 0.5 against the background of OSM raster tiles). In QGIS and Mapbox you can see that the Geographical Survey Institute vector tiles are styled in the same way.

function

--Generation of style.json --Simultaneous generation of binary vector tiles (.pbf files) and style.json

In other words, either generate only style.json, or generate binary data as well. In either case, basically, you can display style.json just by loading it in Mapbox.

Currently it is "Experimental". There are the following known issues:

--Text display is not supported - QGIS size unit only supports MM </ s> → Supports Point and Pixel -Maxzoom and minzoom cannot be specified when generating vector tiles (always max22, min0)

Also, at present, QGIS style expressions are not completely translated into Mapbox.

specification

--Write "all visible layers" to style.json (and binary data) in your project --Each "layer name" in the project will be the "source-layer" in layers in style.json --Each "layer ID" in the project will be the "id" in layers in style.json --Sizes such as width are converted to points by rounding up the integer value. --Raster layer only supports xyz tiles (not compatible with .tif etc.) --Raster layer styling only supports transparency (Opacity) --The MVT Source URL is Optional, but if left blank, dummy text will be inserted and must be entered manually before use. --Binary vector tiles are generated from all displayed vector layers --Binary vector tiles are generated after converting all vector layers to EPSG: 3857. --Binary vector tiles are generated by tippecanoe and mbutil and take a long time depending on the amount of data --Binary vector tiles are written in a directory called "pbf" that is generated in the same directory as style.json

How to use

  1. Start from menu スクリーンショット 2020-02-28 16.11.00.png

  2. Enter and execute in the dialog The file is output by Run. Check Make MVT Source to generate binary vector tiles. スクリーンショット 2020-02-28 16.11.39.png

  3. style.json (and binary vector tile) is output to the specified directory スクリーンショット 2020-03-03 18.51.30.png

At the end

It's shaped better than I expected. It needs a little more brush-up, but I thought it would be better to publish it first and receive feedback to fix it, so I released it. It was just Cloud funding to support vector tiles in QGIS started, so the timing Whether good or bad, there is no doubt that vector tiles are in widespread use. Keep an eye on future trends.

Recommended Posts

Generating and styling vector tiles in QGIS "MBStyle Generator"
Add vector tiles as layers in QGIS
Inner product and vector: Linear algebra in Python <2>