QGIS
Accessing OS Features API via QGIS
Last updated
Accessing OS Features API via QGIS
Last updated
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.
QGIS version 3.4 or later.
A preloaded base map, for example OS Maps API or OS Vector Tile API.
OS Features API URL and key. See Getting started with an API project for more information.
We used QGIS version 3.4. to create these instructions
Open a blank document in QGIS. Uncheck the Render box for now.
Navigate to Layer > Add Layer > Add WFS Layer...
In the Data Source Manager | WFS dialog, click New in Server Connections to configure a new connection. If you have previously connected to OS Features API using a WFS connection, you can ignore steps 3 and 4 and move on to step 5.
In the Connection Details dialog:
Provide 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 100.
Page size: Enter 100.
As a best practice, we recommend you limit your max number of features and page size to 100
to ensure a smooth service. Larger values may result in a very slow response.
Other fields: Leave the rest of the fields as they are.
Click OK to save the information and close the dialog.
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.
In the Data Source Manager | WFS dialog, connect to the WFS service in Server Connections:
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.
Click Connect. A list containing the title and name of all feature layers available in OS Feature API will display in the large box.
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.
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.
We recommend you uncheck the layer/s you called in the Layer panel as a precaution. 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.
Zoom to your desired scale. We recommend a scale of 1:1,500 or below for WFS requests to multiple layers.
Next, configure a scale range:
In the Layers panel right click on a layer and click Properties in the context menu. You can also double-click the layer name.
In the Layer Properties dialog Click Rendering in the left navigation to open the Rendering tab.
Select the Scale Dependent Visibility option (first field). This activates the manual options.
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).
Click Apply.
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.
You can now 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.