# 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 WFS).

These instructions demonstrate how to integrate and apply the OS Features API into QGIS in order to produce a series of topography layers based on our latest OS MasterMap Topography layer data.

## What you need?

{% hint style="info" %}

### Software version

We used QGIS version 3.4. to create these instructions
{% endhint %}

* QGIS version 3.4 or later
* A preloaded base map, for example, [os-maps-api](https://docs.os.uk/os-apis/accessing-os-apis/os-maps-api "mention") or [os-vector-tile-api](https://docs.os.uk/os-apis/accessing-os-apis/os-vector-tile-api "mention")
* OS Features API URL and key; see [getting-started-with-an-api-project](https://docs.os.uk/os-apis/core-concepts/getting-started-with-an-api-project "mention") for more information

## Instructions

{% hint style="warning" %}

### Editing existing connection details

Restart QGIS after editing the connection details for the changes to take effect.
{% endhint %}

{% stepper %}
{% step %}

### Open a blank document in QGIS.

Uncheck the *Render* box in the bottom toolbar for now.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-652ed7d8a9e1cbfc19bf2457369f0579f00c497a%2Fimage.png?alt=media" alt="QGIS UI highlighting Render option"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Open the Add WFS Layer window

Navigate to Layer > Add Layer > Add WFS Layer

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-a193dcc5a8993eb16dc5d297ca8bbeffb2e7ddfe%2Fimage.png?alt=media" alt="QGIS UI showing Layer > Add Layer > Add WFS Layer...navigation option"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### *Click New in Server Connections in the Data Source Manager | WFS dialog to configure a new connection*

If you have previously connected to OS Features API using a WFS connection, you can ignore steps 3, 4 and 5 move on to step 6.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-e53fe82eba95f2610d573b05bc256e12d714c226%2Fimage.png?alt=media" alt="QGIS Data Source Manager | WFS dialog"><figcaption><p>QGIS Data Source Manager | WFS dialog</p></figcaption></figure>
{% endstep %}

{% step %}

### Set up a new connection using the Connection Details dialog

&#x20;Add the service details for your new connection:

* **Name**: Provide a name for the API. It is good practice to name your connections in a way that makes them instantly recognisable.
* **URL**: Copy your OS Features API endpoint address from the OS Data Hub and paste it into this field. Your API Key is automatically added to the URL in the `key` parameter.
* **Authentication**: You can ignore these options. It is not necessary to enter your username and password to use the service as all authentication is done through your OS Features API key.
* **Version**: Click *Detect* to identify the WFS version number.
* **Max. number of features**: Enter a value between 100 and 1000. Larger values allow for a greater number of map features but may result in a slow response.

  **Page size**: Enter a value between 100 and 1000. As a best practice, we recommend you start with limiting the number of features and page size to `100` to ensure a smooth service. This can be increased to a maximum of 1000 to allow for more features to be loaded at once.
* **Other fields**: Leave the rest of the fields as they are.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-0fe8b50ae9dd7f547d395a091f9c36e2e55cc5a4%2Fimage.png?alt=media" alt="QGIS Connection Details dialog"><figcaption></figcaption></figure>

You are not required to provide styling, zoom or coordinate information in the URL. This will be added at a later stage by your GIS application.

QGIS saves your connection details. You can reuse this connection with any of your geospatial projects.
{% endstep %}

{% step %}

### Connect to the WFS server in the Server Connections window of the Data Source Manager

1. Select your connection to the OS Features API in the dropdown. If you called the OS Features API before, the connection will be available as an option in the dropdown.
2. Click *Connect*. A list containing the title and name of all feature layers available in OS Feature API will display in the large box.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-88da58b6eaea6c7258a84447b1b2784c7254e3cd%2Fimage.png?alt=media" alt="QGIS Data Source Manager | WFS dialog showing Server Connections options"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Select the feature layers you want to add to the map

As a best practice, only load feature layers that you need. This depends on what you're attempting to do. For example, to simulate the OS MasterMap Topography Layer you may need to load all layers, but when using backdrop mapping for visualisation, interrogation and analytical purposes you may only need to load an interest-specific layer.

* Click the layers you want to apply. You can select multiple layers using your Ctrl/Command key.
* Check the *Only request features overlapping the view extent* box (if not already selected). This option engages the bounding box and ensures that only features within the viewing window load (not everything). Your viewing window in your GIS application sets your bounding box.
* Click *Add*.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-de69422cca2296a049f0d6eff97009f342ec3572%2Fimage.png?alt=media" alt="QGIS Data Source Manager | WFS dialog showing OS Features API layers in Server Connections"><figcaption></figcaption></figure>

Depending on the features you selected, adding the layers could take several minutes. The more types of features you call, the longer it will take to load into the GIS. Please be aware that each feature, regardless of its layer, counts towards the request restriction.
{% endstep %}

{% step %}

### (Recommended) Uncheck the layer/s you called in the Layer panel

This limits the amount of feature transactions used. However, because the Render option is unchecked (see instruction in\_ step 1 *above), the layer selection will not cause data to be loaded immediately.*

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-103f7e7850c6b3b5b7cf129bb387a6d600d00b04%2Fimage.png?alt=media" alt="QGIS UI highlighting Layers checkbox"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Zoom to your desired scale

We recommend a scale of 1:1,500 or below for WFS requests to multiple layers.
{% endstep %}

{% step %}

### Configure a suitable scale range

1. In the Layers panel right click on a layer and click *Properties* in the context menu. You can also double-click the layer name.
2. In the Layer Properties dialog Click *Rendering* in the left navigation to open the Rendering tab.
3. Select the *Scale Dependent Visibility* option (first field). This activates the manual options.
4. Enter your scale options in the Minimum (exclusive) and Maximum (inclusive) boxes. Rather counter-intuitively, you want the higher value in Minimum (exclusive) and the lower value in Maximum (inclusive). 'exclusive' and 'inclusive' means that in order to obtain your entire range, you need to input your minimum value +1 and your maximum value -1. This allows the layer to display up to and including the selected values. The example below shows how this is taken into account for a scale ranging from 1:1,500 (1,501) to 1:50 (49).
5. Click \_Apply.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-62c00b486ae777318d8c8c6592675308ae33dc29%2Fimage.png?alt=media" alt="QGIS Layer Properties dialog highlighting Minimum and Maximum scaler options"><figcaption></figcaption></figure>

You can now optionally click *OK* to close the Layer Properties dialog. The Style dropdown (bottom left) allows you to load a predefined stylesheet or customise your own.
{% endstep %}

{% step %}

### Check the layer checkbox in the Layers panel, as well as the Render checkbox in the footer, and use the data as intended

QGIS will automatically stop calling features should you need to zoom out and reposition your bounding box area of interest.

<figure><img src="https://4043944746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoEzqrBzRGoJw7nQyLj1W%2Fuploads%2Fgit-blob-adf37eb081ec9baa96c4804e27882133d7f5a132%2Fimage.png?alt=media" alt="QGIS UI showing OS Features API data in the map and highlighting Layer and Render checkbox options"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
