Loading vector sata
Last updated
Last updated
The guides below detail how to load vector data for the following products:
It is assumed that the user will have already set the default co-ordinate reference system in QGIS to British National Grid (EPSG 27700).
Open QGIS. Select ‘open vector layer’ from the left hand toolbar.
In the next window, click ‘browse’ and navigate to the folder in which the OS OpenMap-Local shapefiles are located.
OS OpenMap-Local data is comprised of a number of shapefiles containing different elements of the whole dataset. It is up to the user as to which elements are loaded depending upon requirements. In this example, all of the main elements will be loaded into QGIS. After selecting the files required and clicking ‘open’ twice, the user will be presented with the data loaded.
In the example below, the SU 100km grid tile has been loaded.
It will be noted that some features extend beyond the tile edge. This is indicative of the ‘hairy tile’ supply. The layers will need to be ordered correctly in order to display correctly, so that the polygon data does not cover the line and point data. A suggested layer order is shown below, but the user may wish to change this as per requirements.
It should be noted that initially, it is easier to turn off the functional site layer whilst styling is applied to the other layers. The functional site layer is an attribution layer which highlights various important sites and does not form part of the map base itself. Performance will be improved by adding a spatial index to each of the layers. Right click each layer in turn. In the context menu, select ‘properties’ and then click the ‘general’ tab. The ‘create spatial index’ button will be seen just below the co-ordinate reference system box. Each layer can be styled to appear as per user requirements. In QGIS, style files are identified by having the extension .QML. To add a style to a layer, right-click on the layer in the layer window and select ’properties’. Click the ‘style’ tab. The user can now either style the data using the various tools available or by loading a predefined style from a .QML file. For more information, please see the Getting Started with QGIS guide referred to at the beginning of this section. Ordnance Survey has released a set of style files for OS Open Map for QGIS. These will be available on the Ordnance Survery GitHub repo here. Instructions for layer ordering and loading of these styles are provided in the Quick Start Guide which is included with the style files.
The example above is styled using the published OS OpenMap-Local style files and layered according to the instructions included in the Quick Start guide available with those files.
The user may have a requirement to load more than one 100km2 grid square to cover the area that is required. 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 100km grid square reference letters as shown below.
Each shapefile element of OS OpenMap-Local will need to be merged separately in order that the user obtains a shapefile, for example, buildings, covering the whole area of interest. It is recommended that the user copies each of these elements into a new empty folder before merging is carried out. In the case shown above, the buildings shapefiles for SU and TQ have been copied to an empty folder. 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, and also the folder where the files to be merged will reside. In this example, all of the files in the folder specified will be merged, which is easier than defining individual files. Finally, an output folder and filename for the merged shapefile needs to be selected. The user can also specify if they want the newly merged file to be automatically added to the map canvass.
Once ‘OK’ is clicked, QGIS will create a merged shapefile covering the element of the grid tiles required. In this example, the building shapefiles for SU and TQ are being merged. This procedure will need to be repeated for all of the other layer shapefiles for OS OpenMap-Local which the user requires.
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. In the case above, styling can now be applied to the data as described previously in this guide.
As has already been stated, OS OpenMap-Local data is supplied as ‘hairy tiles’ with features which cross a 100km2 tile edge being supplied in both tiles in which the feature appears. In many instances, the user will simply wish to use the merged OS OpenMap-Local data as a contextual backdrop map. 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 SU_TQ Buildings file that we created in section 2.1.2. 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 SU_TQ Buildings 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 filename for the
de-duplicated data. Once this is done, the user can specify whether or not 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. The new shapefile containing the de-duplicated data can now be loaded into QGIS. Once again, it is highly recommended that the de-duplicated file be given a spatial index using the method previously described to improve rendering performance
The data can now be styled with a suitable style as per user requirements using the procedures as described earlier in this guide.
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 file 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.
Another window will appear which will allow the user to select which layers of the data to load. If all of them are required, click ‘select all’.
The data will now load into the map window.
In the example below, just the roads and buildings from the SU tile were selected.
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 shapefile supply of the data will not work with GML supply without modifications. It is highly recommended that style files created specifically for the GML supply be used.
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 100km² tiles of OpenMap .GML data cannot easily be merged together as with the shapefile option and as a consequence, 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. This is not covered in this guide.
There are two possible ways of loading and displaying the shapefile data in ESRI ArcGIS. The shapefile data can be loaded straight into ArcGIS. However, if more than one 100km2 tile is being loaded, the rendering performance can become an issue. The recommended way of loading the data is to use a file geodatabase to house the data. This is the method which will be described in this guide.
Open ArcCatalog. Choose a folder where the file geodatabase is to be created.
Right click on the folder and in the context menu select ‘new’ and then ‘File Geodatabase’. Give the new file geodatabase a suitable name for ease of reference by highlighting the geodatabase and typing a new name.
Once created, right click on the file geodatabase and select ‘import’ and then ‘feature class (multiple)’.
In the next window, browse to the location where the data resides which is to be imported. Because the individual shape files begin with the 100km prefix, it is possible to import more than one OS OpenMap-Local tile into the geodatabase as per user requirements.
Click on the button to the right of the blank window under ‘input features’ and navigate to the folder where the OS OpenMap-Local shapefile data resides.
Select all of the shapefiles that are required in the window and click ‘add’.
The shapefiles selected will now appear as a list in the import feature class window. The output file geodatabase should default to the one which has been previously selected. Click ‘OK’. The window will close and now ArcCatalog will import the features classes into the file geodatabase. A dialog box will appear when the process is complete.
If the file geodatabase is now highlighted, a list of the imported features classes should be visible. In this example, both SU and TQ shapefiles have been imported.
A useful point to note is that loading the shapefiles into a file geodatabase will automatically add spatial indexes to the data in the import process. There is therefore no requirement to manually add one once the data has been loaded, which would be the case if shapefiles had been loaded into ArcGIS without using the file geodatabase option. As has been previously mentioned, the addition of a spatial index greatly improves rendering performance.
Start ArcMap. Click on the ‘import data’ button in the top toolbar.
In the window that appears, navigate to the location of the file geodatabase just created. Select the feature classes that are required and click ‘add’.
The data will load into ArcMap. Although ArcMap does put the shapefiles into a more logical sequence, the user can move the layers according to the desired preferences. The data will, of course load in as un-styled data. ArcMap will assign a random style to the data.
The user can manually style each of the layer files by right-clicking on each of the loaded layers, selecting ‘properties’ and then ‘symbology’. ArcMap contains an extensive range of tools to allow the user to apply various styles to each layer of the data and then save the work as an ArcGIS layer file. This procedure is not covered in this guide.
A set of ESRI layer files for OS OpenMap-Local will be available for download from the GitHub web site at product launch. Follow the instructions in the Quick Start Guide which accompanies these files to apply the styling to the data. These style files will work with either a direct shapefile load in ArcMap or using the file geodatabase methodology described here.
The user should see something like the screenshot above when the process is complete.
If using a different set of layer files, the procedure for adding a style in ArcMap is as follows – this method can be used for many other data types. To add a style to a layer, simply right-click on a layer, select ‘properties’ and then ‘symbology’
In the layer properties window, select ‘import’ (the button below the tabs at the top). A list of available styles, drawn from the imported layer file will appear. Simply select the required style and click ‘OK’. The symbol in the box will now change to the predefined style.
Click ‘OK’ again and the style will then be applied in ArcMap. Repeat this procedure for all of the layers until the OS OpenMap-Local data is styled to requirements. Labels for certain features can also be applied as required.
If there is a requirement to load a larger area of interest, it is recommended that the user merge the shapefiles together before loading into the file geodatabase. This procedure is described under point 2.2.3. below. Doing this will also mean that the supplied layer files for styling will only need to be applied once to the data and all the styles will work properly.
If however, the user simply wants to load multiple areas using the file geodatabase option, there is no mandatory requirement to merge shapefiles together.
To add another 100km2 tile of data in ArcMap previously loaded into the file geodatabase created earlier, simply click ‘add data’ and repeat the procedure described above for loading the individual layers for the subsequent tile(s). The user may wish to group the layers for each 100km tile loaded in the table of contents window to avoid confusion.
Select all of the layers within the new 100km tile added, right-click and then select ‘group’. The additional layers can be styled as previously using a predefined layer file or manually as required.
This example shows that all of the layers for SU and TQ have been loaded into ArcMap from within the file geodatabase. The file geodatabase option in ArcGIS is also useful in that if the user wishes to add another tile of data at a later date, the shapefiles can be simply imported into the same file geodatabase using ArcCatalog and then displayed in ArcMap.
As has already been stated, OS OpenMap-Local data is supplied as ‘hairy tiles’ with features which cross a 100km tile edge being supplied in both tiles in which the feature appears. These duplicate features will occur if more than one 100km2 tile is loaded into a file geodatabase. In many instances, the user will simply wish to use the OS OpenMap-Local data as a contextual backdrop map. 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.
To remove duplicate features in ArcMap, it is necessary firstly to merge the elements of the tiles together before removing the duplicate features. This procedure can take some time, so the user should consider if this requirement is really needed.
The elements of the data first need to be merged together to create new features classes within the file geodatabase containing the original data (or to a completely new file geodatabase or shapefile if required).
Using either ArcMap or ArcCatalog, from the main menu, select ‘Geoprocessing’ followed by ‘merge’.
In the next window, select the layers to be merged. In this example the SU_Roads and TQ_Roads are being merged together. All of the attribution is being copied into the new shapefile though the user can specify what attributes need to be copied. The user can also specify the output required. This can be a new feature class within a file geodatabase or a shapefile. In this example a new shapefile containing the merged data will be created.
Click ‘OK’ when all of the elements to be merged have been selected. It can be seen using this method, the roads element of a number of 100km tiles could be merged together, although only two are shown in this example. ArcGIS will then merge the files and load the newly created shapefile into the map window. Depending upon the sizes and number of of the data layers being merged, this could take some time. A dialog box will appear when the process is finished.
In the example shown below, a new file geodatabase has been created to hold a set of merged shapefiles covering the SU and TQ grid squares. These have been styled using the style files for OS OpenMap-Local available from Github. As stated above, it is important that the instructions provided in the Quick Start guide, that accompanies these files, be followed to obtain the intended end result.
The ‘Dissolve’ function in ArcGIS will remove the duplicated features along the tile boundaries. This procedure can be carried out in either ArcCatalog or ArcMap. Firstly, select ‘Geoprocessing’ and then ‘Dissolve’ from the main menu.
The user will then need to specify which merged file from which duplicate features are to be removed. In this example we are looking at the SU_TQ_Merged road file.
We are going to save the new feature class as a new shapefile called ‘Dissolve_SU_TQ_Roads’. All of the dissolve fields in the box need to be ticked except the FID field as otherwise the attribution will not be carried over to the new dissolved file. Once complete, the dissolved layer will be loaded into ArcMap. This merged file will contain no duplicate features. It can now be styled as previously described. A count using the attribute table on both the original merged file and the dissolved file will confirm that the dissolved shapefile contains fewer features