It is assumed that the user will have already set the default coordinate reference system in QGIS to British National Grid (EPSG 27700). Instructions on how to do this can be found in the QGIS Getting Started Guide:
Click on the ‘browse’ button in the next window.
In the next window, navigate to the folder in which the data has been stored following download.
Select the files which need to be loaded and then click ‘open’.
Click ‘open’ again in the following window:
The data will now load into QGIS and will look something like the following:
The data will be loaded un-styled. It will be noted that the data will be loaded by tile reference as shown in the layers panel window of QGIS on the left-hand side of the screen. For small amounts of data, loading in this way will be perfectly acceptable. However, for larger areas, it will be more manageable to merge the data together to load larger areas as one file.
The user may need to load more than one 10000 km² grid square to cover the required area. The user will need to extract the relevant shapefiles from each tile into a folder. In the final release of data, the individual shapefiles will be prefixed with their National Grid 100 km grid square reference letters as shown below:
In OS Open Greenspace, there are two elements of the shapefile data, one for the Greenspace sites and one for the access points. These two elements will need to be merged separately from each other, so that the user will obtain a larger shapefile for the sites and one for the access points.
It is recommended that the user copies each of these elements into a new empty folder before merging is carried out. In the example below, the Access Points for two tiles of OS Open Greenspace have been copied into a ‘Merged_Data’ folder. This will need to be repeated for the Greenspace sites
To merge the shapefiles together in QGIS, from the main menu, select ‘vector’ then ‘data management tools’. The ‘merge shapefiles to one’ option is towards the bottom of the list of options.
In the next window, the user will need to define if the shapefiles to be merged are either points, lines or polygons. OS Open Greenspace contains two layers, the Access Points are point data and the Greenspace Sites layer is a polygon layer. Additionally, the folder where the files to be merged will sit needs to specified. In this example, all the files in the folder specified will be merged, which is easier than defining individual files. Finally, an output folder and file name for the merged shapefile needs to be selected.
The user can specify if they want the newly-merged file to be automatically added to the map canvass. Click ‘OK’ when satisfied with the files to be merged and the name and location of the output file has been decided.
Click ‘Close’ on this window when the process is completed. If the user selected the ‘add result to map canvass’ box, the data will appear. In the example below, two tiles of OS Open Greenspace, containing Access Points and Greenspace sites in separate layers, have been merged and loaded.
When working with merged shapefiles of any kind, it is highly recommended that a spatial index be applied to each element of the data, particularly if the user is loading national sets of data. The performance improvement in rendering the data will be very noticeable. To do this, carry out the following procedure:
Right-click on the table in the layers pane on the left-hand side of the screen. In the context menu which appears click ‘Properties’.
In the next window, select the ‘General’ tab on the left and then click on the ‘Create Spatial Index’ button.
Click ‘OK’ when this is done. If working with larger shapefiles, the user will notice a distinct improvement in performance in rendering and panning the data.
At the time of writing this Getting Started Guide, the plan is to make available pre-defined style files for Open Greenspace in both ESRI shapefile and GML output. The style files for QGIS are files which have the .qml extension. These are available to download from the Ordnance Survey Github pages.
It is also possible to style the Greenspace data manually using the tools available within QGIS to produce an output which suits the data user’s needs.
To style an element of the data, right-click on the table in the layers pane and in the context menu, select ‘Properties’.
In the next window, select the ‘Style’ tab on the left-hand side of the window. The user will see something like the following:
It’s now up to the user as to how to style the data. However, for the OS Open Greenspace data, a categorized approach, based upon the attributes within the data, is the logical approach.
Using the drop-down box in the style window, select ‘Categorized’ from the list of options.
In the next window, select the column within the data which is to be used for defining the categories. For the Greenspace Sites layer it will be ‘function’.
The user will now need to add all the categories which make up the different elements of the data. Click the ‘classify’ button towards the bottom of the window.
Once this has been done, a list of categories will now appear in the main window.
Each of the categories will have been assigned a random style by QGIS. To change these, the user should select each category in turn, and using the tools within QGIS, assign their preferred style.
In this example, we are going to style the Allotments or Growing Spaces areas. Double-click on the feature in the list.
The style assigned by QGIs is a simple fill. We are going to keep this but change the colour to something more appropriate. Click on the ‘Simple fill’ box beneath the ‘Fill’ entry.
Another set of tools will now open. Select the drop-down next to ‘Fill’ in Colours.
The user has the option to select from a choice of recent colours or copy, pick or choose a colour using the appropriate menu option. In this example, we will choose a recently used colour. We have also selected a transparent border for the feature.
Click ‘OK’ when finished.
The new colour has been applied to Allotments and Growing Spaces. This will need to be repeated for all the remaining categories, using an appropriate colour for each. When finished, click ‘OK’ at the bottom of the window.
In the example above, we see that QGIS has applied the style to the Allotments features.
To load a predefined style file for OS Open Greenspace, click on the ‘Style’ button at the bottom of the window. Then click on ‘Load Style’.
Another window will open to allow the user to browse to the location of the style file (ending in .qml).
In this example, we will select the Greenspace_Site.qml. Click ‘Open’.
The window will now change to a view of the categories in the predefined style as determined by the style file.
The styling will now be applied to the data. In this case, the Greenspace Sites will be styled.
The data will now look something like the above. Styling can also be applied to the Access Points by either styling manually or by adding a predefined style something like the below.
When using the predefined style files available from Github, it is important to consult the quick-start guide with those files for their correct use.
If the user wants to save a style file they have created, they should follow the procedure below:
Click on the layer for which the styling is to be saved. Right-click and select ‘Properties’ to bring up the properties window. Select the styling tab on the left-hand side of the window as previously.
At the bottom, click on ‘Style’.
There is now a context menu which allows the user to save the style as a QGIS Layer style file. Select that option.
In the next window, provide a style name and save it to a location. It is suggested that the user saves the style in a new empty folder to make managing style files easier.
In the example, we are saving the style file as Greenspace Site.QML.
Click ‘Save’. The file of type should be a QGIS Layer Style file, as we are not saving the style into a database or as a Styled Layer Descriptor in this instance. The style file is now saved and can be loaded into QGIS in future to style updated OS Open Greenspace data or data from a different location. It should be noted that this process needs to be repeated for the Access Points file in the OS Open Greenspace data as separate style files for the access point and greenspace sites shapefiles will need to be produced.
OS Open Greenspace data is supplied as ‘hairy tiles’ with features which cross a 100km tile edge being supplied in both tiles in which the feature appears. In many instances, the user will simply wish to use the Greenspace data as merged. In this case, there will be no need to remove duplicate features along the tile edges as the features will display perfectly clearly with one duplicate feature overlying the other.
There may, however, be instances where the user wishes to carry out some form of analysis using feature counts contained within the data. In this case, the data will need to have the duplicate features removed. There are several ways within QGIS to achieve this. There are also several plugins for QGIS which can be installed to carry out this function, in particular, one called ‘MMQGIS’. However, methods using these options are not described here.
The ‘Dissolve’ function in QGIS which is part of standard functionality will effectively carry out this procedure. In the example described below, we are going to de-duplicate the merged OS Open Greenspace file that we created in the section on merging shapefiles in this guide. In this example described, we have the file loaded into the map window.
From the main menu, select ‘vector’ then ‘geoprocessing tools’ followed by ‘dissolve’. Another window will then appear.
The user will need to select the input vector layer to be de-duplicated; in this case, the Merged_Greenspace_Sites file is already selected. The dissolve field is set to ‘id’ which will be the field in the data which will be searched for duplicate features. Finally, the user will need to specify an output folder and file name for the de-duplicated data. Once this is done, the user can specify whether the newly created file can be added to the current map canvass.
Click ‘OK’ to start the process.
A message appears once the process is complete. In this example, we have asked QGIS to automatically load the dissolved file. Once again, it is highly recommended that the dissolved file be given a spatial index using the method previously described to improve rendering performance.
Compared with the data which contains duplicates, the de-duplicated data should contain fewer features.
This can be confirmed by either running a COUNT query in an expression window or by simply opening the attribute table of the data and comparing the number of features.
In the example above, which is the original merged file, there are a total of 4473 features as seen in the attribute table.
In this example, which is the dissolved file, there are now only 4468 features in the layer, so the duplicate features have been removed.
Styling can now be applied to the dissolved file if required. The same style files created earlier or downloaded from Github should work with the dissolved file because no column headers or other changes have been made to attribution.
Open QGIS. Select ‘open vector layer’ from the left-hand toolbar.
In the resulting window, click ‘browse’ to open the window, which will allow the user to select the .GML files to be loaded. The user will need to specify that a .GML (geography mark-up language) file needs to be opened from the drop-down menu at the bottom of the window.
Select the file and then click ‘open’ twice. The .GML data for the OS Open Greenspace contains two elements which make up the data, namely access points and greenspace sites. After selecting the .GML files to load and clicking ‘open’, an additional window will appear:
The user should select the elements from the data which are needed and then click ‘OK’. If both are selected, the user will see something like the example below (the polygons being the greenspace sites and the points being the access points):
The data can now be styled using a predefined style file (.QML file) as described previously or using the tools within QGIS. Please note that style files created for the shapefile supply of the data may not work with GML supply without modifications. It is highly recommended that style files created specifically for the GML supply be used.
The styled data will appear in similar fashion to that shown below. In this instance the style files created for the ESRI shapefile supply do work for the .GML data without modifications.
It should be noted that rendering performance of the data within QGIS will be much poorer than in the case of the shapefile format, as GML data cannot be spatially indexed. It should also be noted that multiple 100 x 100 km tiles of OS Open Greenspace .GML data cannot easily be merged together, as with the shapefile option. Consequently, rendering performance will also be much slower. In addition, it is not easy to de- duplicate features along tile edges using common spatial geoprocessing tools within QGIS. As a result, the GML data itself will have to be queried using code scripts to highlight and remove duplicate features within a text editor. The other option would be to use the QGIS facility of saving out the .GML data as shapefiles and then carrying out additional data processing on the shapefiles instead. However, there would be little point in this as one of the OS Open Greenspace supply options is ESRI Shapefile.
Open QGIS. Select ‘Add Vector Layer’ from the left-hand toolbar.
Then, click ‘Apply’ followed by ‘Open’.