[PYTHON] Add vector tiles as layers in QGIS

Introduction

Recently, MapTiler service for Japan started has become a hot topic, but what is different from the conventional service? Speaking of which, in addition to raster tiles, vector tiles were delivered. I won't explain what vector tiles are, but I feel that they are an indispensable element in recent map distribution, and I'm playing around with them. If you are a FOSS4G kid, you want to display vector tiles in QGIS, right? In this article, I will introduce how to display (plug-in).

Target

Load the vector tile as a QGIS layer as shown below. If this happens, you can output the layer you want to an external file, and your dreams will spread! スクリーンショット 2020-02-10 23.15.18.png © MapTiler © OpenStreetMap contributors

Vector Tiles Reader https://github.com/geometalab/Vector-Tiles-Reader-QGIS-Plugin It is also listed in the official repository, so it can be installed seamlessly from QGIS.

How to use

スクリーンショット 2020-02-10 22.55.46.png

スクリーンショット 2020-02-10 22.56.29.png

You can add preset layers such as MapTiler.com, but this time we will consider adding any vector tile.

How to add

When you press New at the bottom of Connections, a dialog like the one in the image above will be displayed. Enter the following and save.

--Any character string for Name --URL of tiles.json in Tile JSON --The URL of style.json is (Optional) for the GL Style JSON URL.

If you don't know the URL of tiles.json but you know style.json, you can also find the location of tiles.json by looking at the contents of style.json (try searching the file with tiles.json). style.json is optional and works without it, but if you have some defined style.json, it's obviously better to add it.

Select the vector tile you want to add from the pull-down menu, click "Connect", and then click "Add" at the bottom to add the layer. If you want to add only some layers to QGIS, select the layer you want to add from Layers of ~ and then add (if not selected, all layers will be added). After that, until the added group is deleted, the data will be brought from the server each time the screen area (including zoom level) is changed.

important point

Do not "Add" outside the scope of vector data

Currently, if you add in an area where vector tiles are not provided, it will not be reloaded. Especially immediately after startup, the display area tends to be strange, so add an affordable layer (such as XYZ Tile) to narrow down the display area before adding.

Style.json styling with multiple sources is not supported

As the title says. For example, JP MIERUNE style.json of MapTiler.jp has 4 data in sources, so it is not styled by this plugin at all. This can be seen from the fact that style.json is optional, because this plugin has tiles.json first and is styling with style.json "if needed". On the other hand, style.json contains a link to tiles.json in the first place, so Mapbox GL JS doesn't necessarily need tiles.json. I think this is a bug, and I have an issue for the time being, so I hope to fix it soon. By the way, if there are multiple data in the sources of style.json like JP MIERUNE, if you process style.json so that only the layers of tiles.json specified in the plugin are styled (tiles that you did not specify). It has been confirmed that the style is reflected properly (if you delete the data for json) (but even in this case, the Japanese character string is not displayed ... I also want to fix this).

Recommended Posts

Add vector tiles as layers in QGIS
Generating and styling vector tiles in QGIS "MBStyle Generator"
Display vector tiles nicely with the official MapTiler QGIS plugin
I have created a plugin to download Geospatial Information Authority of Japan vector tiles in QGIS