Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 Practical 2 Learning objectives: To work with a vector base map within a GIS and overlay point data. To practise using Ordnance Survey mapping data of Great Britain. To learn how to further manipulate QGIS to display maps. To use the GIS to select features from one layer using information from another. Vector Mapping: Symbolising Vector Data. We will create a map showing the location of settlements and urban areas in the UK. We will practise how to symbolise points, lines and polygons and do some simple geo-processing to combine files of the same geometry. Part 1: Bringing vector data into QGIS 1. Open a new map file by clicking on the icon in the top left corner of the interface. You cannot have two map files open at the same time in QGIS so if you have still got Practical 1 open it will ask you to save changes and close it. 2. Click on the Add Vector Layer button on the left of the map: 3. Click browse and navigate to the Practical 2 folder EDINA and Edinburgh University Data Library 1
4. Use Ctrl and click to select the following files then click Open: n_coast_polyline.shp n_settlmnt_point.shp n_urban_region.shp s_coast_polyline.shp s_settlmnt_point.shp s_urban_region.shp This is vector map data in Shape file format. The data is Ordnance Survey Strategi data, available to download from Digimap s Ordnance Survey Collection Data Download service. You should now see a map of the whole of Great Britain similar to the one shown on the next page: NOTE: The data appears in two halves, one for the north of the country and one for the south. The data is split into 2 tiles. In the rest of this practical we will look at ways of symbolising and manipulating the data so that the data appears as a single continuous dataset. At this point it is also a good idea to save our map again; do this in the same way as before: 1. Click Project then Save as 2. Save the file in the same folder as the data and give it a suitable name such as Practical2. 2 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 Part 2: Joining vector datasets The first way we are going to get the north and south data to match is to actually join the two halves of each dataset into a new single dataset. This operation will only work on files that have the same geometry type, points with points, lines with lines etc. The process will run very smoothly with these datasets as they have identical attributes. There are two possible tools to use merge and union. The merge tool is ideal for merging multiple files in a folder into one file, the union tool is good for two layers that are in the same project. We will use the Union tool in this instance. 1. Click on the Vector menu 2. Click on Geoprocessing Tools. 3. Click on Union. 4. Select n_coast_polyline as the Input vector layer. 5. Select s_coast_polyline as the Union layer. 6. Click Browse and select the folder that contains the data to save the Output Shapefile in, give it a sensible name like full_coastline.shp. Click Save 7. Click OK EDINA and Edinburgh University Data Library 3
8. There will be a short wait then the file will be added to the map. Click Close on the Union Window Now we have the full coastline as a single file we can give it the right symbology which will be consistent across the whole dataset. 9. Clear the n_coast_polyline and s_coast_polyline layers from the map by unchecking their boxes. 10. Double click on full_coastline to open up the Layer Properties, change to the Style option. 11. Click on Simple Line and change the colour to be Blue. 12. Click OK to apply the change to the map. You should now have a blue coastline. 13. Save your work and we can then move on to the next section. 4 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 Part 3: Simple map symbologies If you aren t doing any analysis with your files and don t need to merge your datasets you can simply make them look the same. 1. Switch the two urban_region files back on in the table of contents. 2. Zoom in to the centre of the UK around the Liverpool area. 3. Right-click on the n_urban_region and click on Properties 4. Switch to the Style tab 5. Click on the coloured square next to where it says Simple fill. EDINA and Edinburgh University Data Library 5
. 6. Set the Fill Color to 50% grey, as shown below, and set the Border Style to No Pen. 7. Click OK on the Style window The map should update to reflect the changes. 6 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 8. Repeat this process for the s_urban_region. You won t be able to see the division between the two tiles anymore. 9. Save your work and we can then move on to the next section EDINA and Edinburgh University Data Library 7
Part 4: Symbologies based on categories We can use the information in a layers attribute table to create categories for the symbols. Information like population size or status can be used to vary the symbol for a settlement for example. 1. Switch on both the sttlmnts_point files in the table of contents. 2. Right-click on the n_sttlmnts_point layer and click on Properties 3. Select the Style window. 4. Where the tab has Single Symbol change this to Categorized. 5. Change the Column to LEGEND. 6. Click Classify, you may have to wait a moment while it checks all the records. You should end up with three categories. 7. Uncheck the blank box at the bottom of the list, where you would select the symbol for features with a null value. 8. Double-click on the point in the Symbol column for the City Attribute Point to open the Symbol Selector, and click on the Icon by the text Simple marker. 9. Change the Shape to Square, the size to 4, and the Fill to be Yellow. 8 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 10. Repeat this process for the Town and Village Attribute Points but decrease the Size to 3 and then 2. You can now see that the symbols on the map are graduated depending on the status of the settlement You can go back into the Style window to change the Labels of entries in the Table of Contents. Here we can tidy up what appears in the table of contents; knowing how to do this will also help later when we come to make a legend for a printable map. 11. Right-click on the n_sttlmnts_point layer and click on Properties and open the Style window. 12. Double-click on the entries on the label column and remove the words Attribute Point to make the Table of Contents tidier. 13. Save your work and then move on to the next section. EDINA and Edinburgh University Data Library 9
Part 5: Exporting & Importing map symbologies We are now going to use the style we just created to apply to the other Settlements on the South sheet. Creating style files is very useful when you have spent a long time creating a complex set of rules and options to style your data. There are two options when using QGIS for exporting your styling rues, QML files which are QGIS specific and SLD which are an open standard but not quite as flexible as QML. 1. Right click on the n_sttlmnts_point file and click on Properties and select the Style window. 2. At the bottom click on the Style button and select Save style QGIS Layer Style File 3. Select Practical2 folder to save the QML file in give it a sensible name like strategi_settlements.qml and click Save. We can now use this QML file to style the other settlements point layer. 4. Right-click on the s_sttlmnts_point, click on Properties and select the Style window. 5. At the bottom click on the Style button and select Load style 6. Navigate to where you saved the strategi_settlements.qml file 7. Click Open and you will see the style has been applied in the Style window 10 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 8. Click OK to see the changes made on the map. 9. Click Apply and OK on the Layer Properties window. 10. Save your work and we can then move on to the next section. This is the end of the basic exercises, there is one further part if you have time. EDINA and Edinburgh University Data Library 11
Part 6: Further categories to symbolise by 1. Open a new map file by clicking on the Icon in the top left corner of the interface. 2. Click on the Add Vector Layer button on the left of the map: and add the Glasgow_Deprivation_Scores.shp file from the Practical 2 Folder. 3. Right-click on the file in the Table of Contents and click Open Attribute Table. 4. You can see that each polygon has the following attributes: a. NAME: This is the Postcode Sector e.g. G66 7. b. POP: Population from the 2001 census. c. CSCORE: Carstairs Deprivation score based on factors such as car ownership, distance to amenities, employment rate etc. d. DEPCAT: The Deprivation values placed into one of 7 categories. e. AREA: The area of the Postcode Sector in square kilometres. You can now try out the following examples of different ways to symbolise the map. 12 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 Deprivation Map Here we will use the deprivation categories and a colour ramp to create a heat map of deprivation in Glasgow. 1. Right-click on the Glasgow_Deprivation_Scores.shp, click on Properties and select the Style window. 2. Where the tab has Single Symbol change this to Categorized. 3. Change the Column to DEPCAT. 4. Click Classify, you may have to wait a moment while it checks all the records. You should end up with seven categories. 5. Click Color ramp at the top right of the tab. 6. Select New color ramp and choose Gradient as the type. 7. Click OK. 8. Pick two colour like Blue and Yellow, when it prompts for a name call it something sensible like Blue to Yellow. 9. Click OK on the Style window to see your changes EDINA and Edinburgh University Data Library 13
Population Map Here we will colour the Postcode Sectors based on their population, try the same as above but using the POP column instead of the DEPCAT column 1. Right-click on the Glasgow_Deprivation_Scores.shp, click on Properties and select the Style window. 2. Where the tab has Single Symbol change this to Graduated. 3. Change the Column to POP. 4. Change the number of Classes to 20. 5. Click the Classify button. 14 EDINA and Edinburgh University Data Library
Using Spatial Data in a Desktop GIS; QGIS 2.8 Practical 2 By default QGIS uses the Equal Interval option which is best for straight forward values such as these. You may want to try natural breaks for other datasets. Population Density Map Here we will change the previous map to show population density rather than population. 1. Go back to the Style Window and click the button next to where you set the column. You have opened up the Expression dialogue where you can input a database expression to use as the value to style the data. This allows you to use information derived from one or more columns 2. Use the buttons to create an expression where the population attribute is divided by the Area attribute: QGIS will now divide the Population field by the Area to create a density ratio. EDINA and Edinburgh University Data Library 15
3. Set the Classification to Natural Breaks (Jenks) with at least 10 Classes. 4. The final map shows the values are now people per kilometre squared rather than just the number of people. NOTE: This method produces a simple density map based on the populations of the postcode sectors. Point based density maps can be created using more powerful spatial analysis tools. You have now completed the second practical! Save your work and we can then move on to Practical 3 16 EDINA and Edinburgh University Data Library