OS Zoomstack Vector Tile Set
Creating a vector tile set of OS Zoomstack data and consuming it in QGIS
In the above post I went through one way of creating a vector tile service using Ordnance Survey (OS) data and then consuming that service in QGIS. However, with QGIS 3.16, QGIS have made it easier than ever to use vector tiles and style them. Although, QGIS brought vector tile support in 3.14, there have been several improvements. QGIS now has internal vector tile support and it is not necessary to use the plugin.
The biggest improvement with 3.16 and vector support is the changes to the styling, you can now import directly from Mapbox style files which makes using vector tiles in QGIS very easy. For this post I am once again going to use OS Zoomstack data which comes in either vector tiles or a GeoPackage free from their OpenData platform.
The vector tiles are in the MBTiles format. MBTiles are essentially a convenient way to store a tile stack without having to move thousands and potentially millions of tile files. They are conveniently stored within one file and is an open specification based on SQLite.
In this post I am going to quickly show how easy it is to use vector tiles within QGIS, in this case to use as background mapping. First we need some vector tiles. Go to https://osdatahub.os.uk/downloads/open/OpenZoomstack and download the MBTile format of the OS Zoomstack data, this is a UK wide open mapping data, find out more information here.
Once we have the data it’s as easy as dragging the data into the map window of QGIS either from Windows Explorer (Finder on Mac) or from the Browser window in QGIS. Once the data has opened up QGIS will use random colours and styling for each feature.
First thing you will notice is how fast the tiles render, this speed will slow down once we style the tiles using one of the official OS style files, I assume due to the more complex style rules and the added work that the processor has to do. If I had one complaint of QGIS current vector tile support is that it doesn’t seem to be utilizing the computer's GPU, which would certainly speed up the rendering even with complex rules applied.
To style the data we need to import the Mabox style files that the OS have released on their Github page here. Download and unzip files to your local machine. The OS has released four different styles, but it is relatively simple to use the OS style files as a template and create our own.
To apply one of the OS styles right-click the Zoomstack layer and open up layer’s properties, then click load style and then using the “from file” dialogue box select one of the OS style JSON files downloaded previously. The map should change to reflect which style file you picked.
There is one more step, due to the way Mapbox styles point markers QGIS doesn’t automatically style the point data. So, to finish the styling we will have to manually add the SVG markers within the Geopackage SLD folder within the style file zip. Firstly copy the SVGs — Airport, LRTS etc from the Geopackage SLD folder. Then locate the QGIS SVG folder — on a Windows machine this is usually stored something like this
C:\Program Files\QGIS 3.16\apps\qgis\svg\
I made a new folder called OS to store them, you may need to re-open QGIS to see the new SVG files.
Then we need to create a new layer — double-click the Zoomstack layer to open up the style dialogue box. Then click the plus sign in the bottom left and add marker. Let’s start with railway stations, add railwaystations in the Layer box and then copy and paste the below into the filter box.
"type" = 'Railway Station'
This will select the railway stations layer but filter out only train stations.
Now double-click the styles to the left, under marker change simple marker to SVG marker.
In the SVG Browser near the bottom of the dialogue window we should now have the SVG files added there before. Click the British rail symbol and change the SVG size to your needs, I have used around 3.5. You should now have all stations in the UK with the official station symbol.
“type” = ‘London Underground Station’
Repeat the last step again but now use the above text and select the London Underground symbol from the SVG files downloaded in the previous step.
After repeating the step for Airports and other point icons we can complete the Zoomstack styling within QGIS. Label conflict and other cartographic issues are beyond the scope of this post, however some tweaks are likely needed. Adjustments to label placements, colours, zoom render levels are now all controllable through the QGIS style manager and adjustments to the mapbox style JSON is not needed. It's worth noting that the identify tool will help identify what each layer and filter type should be, and the MapBox style JSON file will also be useful to determine the data structure for filtering each layer.
There we have it, it is now easier than ever to use vector tile data within QGIS from local vector tiles. I plan to create another post about using server based vector tiles within QGIS.