# 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](/os-apis/core-concepts/getting-started-with-an-api-project.md) for more information.

{% hint style="warning" %}

### CRS

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).
{% endhint %}

## Instructions

{% hint style="info" %}

### 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.
{% endhint %}

{% stepper %}
{% step %}

### 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**.

<figure><img src="/files/567416efb29279b27c584862dac4cae6eb583ff8" alt="QGIS Add Vector Tile Layer option."><figcaption><p>QGIS Add Vector Tile Layer option.</p></figcaption></figure>
{% endstep %}

{% step %}

### Create a new connection in the Vector Tile dialog

In the Data Source Manager | Vector Tile dialog:

* Click **New**
* Select *New Generic Connection*...

<figure><img src="/files/dfe56ddc926b4c7bec42d18d6e4d983f01797377" alt="QGIS Data Source Manager | Vector Tile dialog."><figcaption><p>QGIS Data Source Manager | Vector Tile dialog.</p></figcaption></figure>

In the Vector Tiles Connection dialog:

* **Name**: Provide a name for the connection.
* **URL**: Input the [Tiles](/os-apis/accessing-os-apis/os-ngd-api-tiles/technical-specification/tiles.md) request URL for the OS NGD API – Tiles collection.
* **Min. Zoom Level**: Minimum zoom = 6.
* **Max. Zoom Level**: Maximum zoom = 19.
* **Style URL**: Input your selected [Styles](/os-apis/accessing-os-apis/os-ngd-api-tiles/technical-specification/styles.md) request URL.
* **Authentication**: Leave these settings at their defaults.
* **Other**: Leave all other settings at their defaults.
* Click *OK*.

{% hint style="info" %}

### ngd-base collection

The following are some example URLs to retrieve the `ngd-base` collection:

```
https://api.os.uk/maps/vector/ngd/ota/v1/collections/ngd-base/tiles/3857/{z}/{y}/{x}?key={INSERT_YOUR_API_KEY}
https://api.os.uk/maps/vector/ngd/ota/v1/collections/ngd-base/styles/{styleId}
```

Options for `{styleId}` are:

* `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](/os-apis/accessing-os-apis/os-ngd-api-tiles/what-data-is-available.md).
{% endhint %}

<figure><img src="/files/a3c657d64322068895da81eb1d1da2dfc49f9269" alt="QGIS Vector Tiles Connection dialog."><figcaption><p>QGIS New Vector Tile Connection dialog filled in.</p></figcaption></figure>

{% hint style="warning" %}
You will need to replace the `/{tileMatrix}/{tileRow}/{tileCol}` used in the default [Retrieve Tile](/os-apis/accessing-os-apis/os-ngd-api-tiles/technical-specification/tiles.md) request URL with `/{z}/{y}/{x}` to be able to connect to OS NGD API – Tiles.
{% endhint %}
{% endstep %}

{% step %}

### Create a new connection using a saved server configuration

The Ordnance Survey GitHub repository contains API resources and configuration files that can be loaded directly into the QGIS Data Source Manager following the [Connecting to web services guide in the QGIS documentation](https://docs.qgis.org/3.40/en/docs/user_manual/managing_data_source/opening_data.html#connecting-to-web-services).

{% embed url="<https://github.com/OrdnanceSurvey/osngd-resources/tree/main/api-resources>" %}
Access the OS NGD API resources on GitHub.
{% endembed %}
{% endstep %}

{% step %}

### Add a Vector Tile layer to the map

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:*

<figure><img src="/files/85638f9d39232057cb214c43a3b52a1592cf409e" alt="UI showing OS NGD API – Tiles data in the Layers panel and map area."><figcaption><p>UI showing OS NGD API – Tiles data in the Layers panel and map area.</p></figcaption></figure>
{% endstep %}

{% step %}

### 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](https://maplibre.org/maputnik), you can use this in QGIS. You will need to host the JSON file before using it (for example, on GitHub) and then use the resource URL as your 'Style URL' when setting up your API connection.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.os.uk/os-apis/accessing-os-apis/os-ngd-api-tiles/getting-started/gis-software/qgis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
