Accessing OS NGD data with OS NGD API – Tiles via QGIS
QGIS is an open GIS (Geospatial Information System) desktop application that allows you to display, interrogate, visualise and create geospatial information including from geo-centric APIs (for example, a Vector Tiles Service).
The instructions that follow demonstrate how to connect to OS NGD API – Tiles using QGIS.
What you'll need
QGIS (version 3.22.0 or later).
OS NGD API – Tiles added to an API project in the OS Data Hub with an API Key. See Getting started with an API project for more information.
QGIS currently only supports the EPSG: 3857 version of the tiles. You will however be able to transform the API using a dynamic coordinate transformation into EPSG: 27700 (allowing you to use the vector tile service alongside your British National Grid data).
Instructions
Connecting to OS NGD API – Tiles
If you are connecting to the OS NGD API for the first time then you can follow either step 2 or step 3 to set up a new connection via QGIS. It is not necessary to follow both steps.
1
Set up a new connection
Once a new project with a base map has been set up, select Layer > Add Layer > Add Vector Tile Layer.
QGIS Add Vector Tile Layer option.
2
Create a new connection in the WFS Connection dialog
In the Data Source Manager | Vector Tile dialog:
Click New
Select New Generic Connection...
QGIS Data Source Manager | Vector Tile dialog.
In the Vector Tiles Connection dialog:
Name: Provide a name for the connection.
URL: Input the Retrieve Tile request URL for the OS NGD API – Tiles collection.
3857: Our traditional outdoor style focusing on spaces.
road-3857: Our road style focusing on the transport network.
light-3857: Our light style perfect for overlaying data.
blackwhite-3857: Our high contrast basemap perfect for overlaying data.
Please note: Style URL does not require you to append your API Key as a query parameter.
To learn more about the available collections in OS NGD API – Tiles (e.g. asu-bdy) you can view what data is available here.
QGIS Vector Tiles Connection dialog.
You will need to replace the /{tileMatrix}/{tileRow}/{tileCol} used in the default Retrieve Tile request URL with /{z}/{y}/{x} to be able to connect to OS NGD API – Tiles.
3
Create a new connection using a saved server configuration
Navigate to Layer > Data Source Manager > Vector Tile.
In the Data Source Manager | Vector Tile dialog:
Select your new connection to OS NGD API – Tiles
Click Add.
The layer will then display in the Layers panel and the data will display on the map:
QGIS UI showing OS NGD API – Tiles data in the Layers panel and map area.
5
Add a custom style
You can change the style of features and labels directly in QGIS by right-clicking on the API in the Layers Panel and going to Properties.
If you have a custom style JSON file that you have created in software such as Maputnik, you can use this in QGIS. You will need to host the JSON file before using it (e.g. on GitHub) and then use the resource URL as your 'Style URL' when setting up your API connection.