7. 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.
Create buffer
Create a new QGIS project and save it in the QGIS Training > Essentials folder
Open the nat_parks_england and railway_naptan layers
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)
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
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
7.1. Create centroids and find nearest
Open the boundaryline.county_region layer from the Postgres training database
Find the Centroids process, and use it to create a new layer of the centroids (the centre point) of each county
Use the Join Attributes by Nearest process to add the details of the nearest railway station to each centroid feature
Look at the attribute table for the Centroids table to check the result, and add a label with 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:
7.2. 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:
Select Rectangle (polygon) as the grid type
Use the three dots button to the right under Grid extent to set the extent to the current canvas
Set the spacing values in metres for BNG
Click Run to create the grid
The grid will be loaded in the map - each square is a separate polygon
7.3. 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.