Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Numberedheadings
skip-headingsh3, h4
h1[h1.decimal].
start-numbering-with7
h2[h1.decimal].[h2.upper-latin]

QGIS Geo Processing

This module introduces a few of the common QGIS vector processing functions. In most cases, processes take as input one or more vector layers and create a new vector layer as output. Use the search box in the bottom left of the QGIS interface to find processes - they are all in the Processing Toolbox as well, and some have their own menu options.

Fixed distance Create buffer

  1. Create a new QGIS project and save it in the QGIS Training > Essentials folder

  2. Open the nat_parks_england and railway_naptan layers

  3. In the nat_parks_england layer, Select the Lake District national park (check in the Attribute Table if you are not sure which one this is)

  4. Find the Buffer tool by searching in the Search box, and create a 10km buffer round the Lake District National park - be sure to check Selected features only, and create a temporary layer

  5. Use the Select by location process to find out how many railway stations are within the Buffered layer - look at the attribute table for railway stations to get the count

Create centroids and find nearest

  1. Open the boundaryline.county_region layer from the Postgres training database

  2. Find the Centroids process, and use it to create a new layer of the centroids (the centre point) of each county

  3. Use the Join Attributes by Nearest process to add the details of the nearest railway station to each centroid feature

  4. Look at the attribute table for the Centroids

table
  1. layer to check the result, and add a label

with
  1. showing the name of the nearest station to the

Centroids layer

This process creates an intersection of two sets of geometry - i.e. a new layer representing the shared areas of the input layers, as in the example below. The areas outlined in thick black is the intersect between the green and the hatched layer.

In the search bar, type intersection and select the Intersection tool

Complete the dialog, and click Run in Background to add the intersect layer to the map

Difference

The difference between two vector layers is represented by the areas which are in one but not the other - in other words the inverse of intersection. The Difference tool has a similar dialog to the Intersection tool, with two input layers specified.

Union 

The union tool merges the geometries from two layers into a single layer. Note that it does not dissolve boundaries between features or create multi-polygons, but rather creates features comprising all component parts from the two geometries. To use Union, search in the search bar.

If these are the features to be unioned:
 The result would be as follows:
Note that separate features have been created where there is an overlap - in the screenshot below they have been moved to demonstrate this:

Other Tools

As well as 'standard' geoprocessing functions, QGIS includes a range of useful tools that can be used for research or other purposes - some examples are described here. In each case, use the search bar to load the dialog.

Polygon from Layer Extent

This creates a rectangle (in black) that represents the maximum extent of all the features in a layer.
Random points inside polygons

This is a sampling tool which creates randomly-located points in a new output dataset. This is commonly used to create dot density maps.

The tool requires as a minimum:

  • an input polygon layer to define the area within which the points are created

  • a setting for the number of points to be created per feature, using an attribute in the source polygon data - for example population

The result will be something like this, with the number of dots based on the population of each area:

Vector grid

A vector grid overlaid on a map can be used in analysis, for example showing the density of points within grid squares, or for 'sectorising' an area.

Search for create grid and load the Create grid dialog

  • Complete the dialog in a similar way to the example above:

    1. Select Rectangle (polygon) as the grid type

    2. Use the three dots button to the right under Grid extent to set the extent to the current canvas

    3. Set the spacing values in metres for BNG

    4. Click Run to create the grid

  • The grid will be loaded in the map - each square is a separate polygon

    Analysis Tools

    The tools in this section support data analysis, both spatial and non-spatial.

    Distance Matrix

    This tool calculates the distances between all the points in one dataset and all the points in another, and outputs the results to a new table.

    For example, suppose we have two datasets, Places (A,B and C) and Destinations (W,X,Y and Z).
    Search for distance matrix and open the Distance matrix dialog
  • Complete the dialog as appropriate, and click Run in Background

  • A table like the one below is created, showing distances between all points:

    Sum line lengths

    This tool calculates the total length of a line or line network within an area or multiple areas. Two input layers are required; one containing the lines to be calculated, and the other the areas within which the calculation will be made. The output will be a copy of the area layer, with the total line length within each area as a new attribute.

    Count points in polygon

    This calculates the number of points in a point layer that fall within each feature of a polygon layer. It requires two inputs; the point layer to be counted, and the polygon layer to count inside.

    The output will be a copy of the polygon layer, with an additional attribute for each feature showing how may points are inside it. This attribute can be used with a graduated style to indicate the frequency of points in each feature.
     
    1. centroids layer

    Visualise railway station density

    Using the Create grid tool, create a hexagon grid to cover the extent of the railway stations layer.

    1. Zoom to the extent of the railway stations layer

    2. Create a 30km hex grid for the extents of the layer, with settings as shown in the screenshot - to get Grid extent, click the three dots to the right of the field and use Calculate from Layer

    3. Get the number of stations in each hexagon by using Count points in polygon, and check the attribute table for the results

    4. If you have time and want to try some styling, create an appropriate Graduated style for the grid layer, so that areas with higher concentrations of stations are shown darker than those with no or few stations, and add a label showing how many stations there are in each hexagon