This worksheet shows you how to do the following, using an example dataset:

Firstly you will need to set up a new QGIS ‘project’ folder with a suitable name on your machine. Put it somewhere that is easily accessible. All GIS data you download, acquire and create will be stored in this folder.

Note that GIS data can be very large - sometimes so large that, for example, you cannot easily email them or submit them to Moodle. Thus, you may wish to locate your GIS prject folder on some cloud location such as OneDrive.

Setting up the Project

  1. Open QGIS. Cancel the QGIS Tips window if it appears.
  2. Project > Save As – give the project a suitable name and save it in your GIS folder.
  3. Set the projection properties for the project:

“QGIS allows users to define a global and project-wide CRS (coordinate reference system) for layers without a pre-defined CRS. It also allows the user to define custom coordinate reference systems and supports on-the-fly (OTF) projection of vector and raster layers. All of these features allow the user to display layers with different CRSs and have them overlay properly”

Project > Properties – click on CRS on the left hand side of the window.__

We now need to set the correct co-ordinate system for the project. The following example is in the UK and therefore will use Ordnance Survey maps as a base map. In this case the CRS will be OSGB 1936/British National Grid.

To locate this use the ESPG code: 27700 – in Filter: type 27700 and the CRS will be displayed – highlight. OK.

Save your work.

NB: if you are creating a project that uses the WGS84 coordinate system the ESPG code is 4326.

Each of the coordinate systems in the world has an EPSG code and it is a quick and accurate way of finding them. Go to http://spatialreference.org/ref/epsg/ for details.

The project properties box also allows you to customise the project in other ways – click on each of the icons on the left hand margin of the window for details.

Adding Layers

There are several ways to add data layers.

Click Layer > Add Layer

Then, click on the layer type you want to add as appropriate (for example Add Vector Layer or Add Raster Layer) and navigate to the layer – via Source: * Datasets – click on the three dots in the grey box to navigate to folder (for your chosen layer, add the file **.shp if a vector file)

OR

Navigate to your GIS folder in the Browser Window, highlight the layers required and drag them into the map area (or press the + Add button at the top of the Browser window)

Repeat as required.

To zoom in to a specific area:

On your toolbar you will see a magnifying glass with a cross in it: - click on this and then draw a box around the study location. Keep repeating this until you reach a view that you are happy with. If you wish to zoom back out to the full extent of the map data use the zoom full tool If you want to re-centre the image use the pan map tool to drag it into the required position.

Bookmarks

You may find it useful to create what is known as a Bookmark.
A bookmark identifies a particular geographic location that you want to save and reference later. For example, you might create a bookmark that identifies a study area. As you pan and zoom around your map, you can easily return to the study area by accessing the bookmark.

To create a Bookmark

  • Zoom to the view you wish to Bookmark
  • View > New Spatial Bookmarks
  • Under Name type name of bookmark. Save

To use an existing bookmark:

View > Show Spatial Bookmarks

In the Browser window on the left hand side of the screen Spatial Bookmarks will appear:

Spatial Bookmarks > User Bookmarks - click on the one required

This is a very simple but useful tool, especially if you are moving around the screen to different survey sites for example.

Symbolising

Simple Symbology

Right-click on the layer to be symbolised, > Properties

Click on Symbology on the left hand side of window and alter colour and size as required. OK

Symbolising a Layer to Show Multiple Categories

Suppose we had a layer that contained a categorical variable, such as a name or a species. We might want the objects corresponding to each different category to be coloured differently.

  • Right click on layer to be symbolised > Properties
  • Click on Symbology on left hand side of window
  • Change Single Symbol to Categorized
  • Value: Select column to categorise eg the column that had the species name
  • Color ramp: Select a suitable ramp. For random colours, leave blank.
  • Click on Classify (bottom left hand side of window)
  • Untick All other values
  • OK

Altering the Transparency of the Layers

You may want to make one or more of the map layers semi-transparent so that you can see the layer below it. This can be done as follows:

For each layer as required:

Right click on layer > Properties > Symbology – alter the Opacity using the slider bar as required. OK.

(This is available for the Single Symbol symbology).

Clipping Data

Datasets often cover a much great area than is required. The coverage of the layer can be reduced using a function known as Clipping.

In this exercise we will clip the OSM world map to the bounding box of the UK marine Conservation Zones layer

Vector drop down menu > Geoprocessing tools > Clip

Select as follows:

A new layer will be created and added to the project. Yay!

Changing a csv layer to a shapefile (vector) layer.

You cannot edit the attribute table of a Delimited Text Layer. This is annoying but true. If you need to edit it, a workaround is to export it as a Shapefile (ie a vector layer). To do this, right-click on the layer name in the Layers pane, then export the layer as a Shapefile using Export/Save Features as, as shown below. Finally, load that Shapefile back into your project (as a vector layer), and remove the original layer.

Don't forget to chose the right CRSDon't forget to chose the right CRS

Don’t forget to chose the right CRS

Add a New Field to an Attribute table of a vector layer

To do this you open the attribute table, toggle the Edit pencil (top left) to On, then click on the New Field Icon. ‘Field’ is GIS (actually, database) speak for column. In the window that pops up, choose a name, inh Type box decide what type of data your new field will contain (Integers, Decimals, Text or date) and if you have chosen Text, make sure the ‘Length’ box permits as many characters as you are likely to need. I usually put a number that is plenty big enough, like 50 or 100.

Add a new field to an attribute table

Add a new field to an attribute table

Colouring points according to the value of some numerical attribute

This requires the use of a very short script. Scripting is a very powerful feature of QGIS. So much so that if you become very proficient at QGIS you may well end up doing virtually everything by writing a script full of instructions to do what you want, rather than pointing and clicking at menus.

There are two kinds of language that can be used for scripting in QGIS. One is Python, and the other is SQL, which is the standard language for doing manipulations wih databases. This should not be surprising, since your QGIS is a database, of spatial data. We will use a tiny bit of SQL.

Now, fear not, we don’t to know much at all about programming to do what we need. Hold tight, and off we go:

Suppose we wanted to colour the anemone points at each location according to the size of the cluster found there. For each cluster we have its size recorded in the column “Number” of the attribute table. We would like to create a new column called ‘Size’where in each row we indicate ’Small’ if the cluster size in that row was less than 10, ‘Medium’ if it was between 10 and 50, and ‘Large’ if it was over 50. The cluster size, remember, is recorded in the column called ‘Number’. This will give us three different size categories, and hence three colours for the points in the map.

This is what we could do:

Use of an expression in the field calculator

Use of an expression in the field calculator

We are using the CASE WHEN THEN ELSE function. This is one of many functions available in QGIS. If you click on the function name in the list of functions, you get help on how to use it, including examples.

How to get pop-up information when you click on an anemone

Find the pathway to a project sub-folder

Find the pathway to a project sub-folder

The path (pathway, url) to the folder is shown at the top of the window that opens. Copy this and append the name of the information file file you want to use so that you get (in my case):

Users/michaelhunt/Library/CloudStorage/OneDrive-CornwallCollege/QGIS/fistral/helpsheets/Anemone.docx

It may look slightly different on Windows machines and on Macs. Copy and paste this url somewhere as you will soon need to use it.

Setting a whole field to have the same expression

Setting a whole field to have the same expression

Setting an Open File action

Setting an Open File action

Action: Open file

Action: Open file

Printing maps to pdf documents.

Once you have a map as you want it in the map canvas, go to Project/New Print Layout and eneter a name for the map layout you are about to create.

This will bring up the layout window:

Canvas for creating a new map layout

Canvas for creating a new map layout

Using the Add Item menu, you can now add a map (this be whatever is currently in your map canvas), a scale bar and a North arrow, and many other things.

Finally, print the map to a pdf file.