# Cost paths across the Wolds, part 2

## Digging deeper

This section will provide a little more detail about how I created the maps and worked out the **least cost paths** (LCPs) in Part 1. I’ve tried to keep it as simple as possible, but be warned, it does get a bit technical. Any questions, please leave a comment below.

### Working with cost surfaces

We will need a **cost surface**. Basically, this is a grid of the survey area made up of many cells (or pixels). Each cell has a value that is equivalent to the cost it would take to move into it from a neighbouring cell. Using this we can work out what the accumulated cost is of moving through all cells from a fixed point on a map. This will give us the cost distance to any part of the map, and be able to calculate LCPs.

How exactly am I going to do this? Well, depending on what software you use, the process will vary slightly. I currently use QGIS (v3.4) and GRASS (v7.4). They’re open-source, free and there’s a huge amount of online support for both. They also have all the tools we need to get started.

### Digital Elevation Model (DEM)

The first thing needed is a good representation of the landscape. For this we require a DEM.

There are several places you can download free DEMS. The Environment Agency has a lot of LiDAR data at very high resolution, but it’s still quite patchy over elevated terrain. For this I used Ordnance Survey OpenData, OS Terrain 50. It’s at a much lower resolution (50m) but will do the job for the purpose of this exercise.

### Slope from a DEM

Next up, we need to work out where the slopes are.

The value of a slope, either as a percentage or in degrees,
can be calculated from a DEM. We can use the **r.slope.aspect** function in GRASS to generate a raster (with 50m
resolution) where each cell has a value equal to the percentage steepness of
the slope.

Now we know how steep the slopes are, we need to work out what the cost of going up and down them would be.

### The cost of slopes

There is no ‘one rule fits all’ way to work out the cost of moving across slopes. Herzog (2013) outlines a number of formulae to calculate costs, each with its pros and cons. For this I’m using…

**Cost (s) =
1 + (s / ****š****) ^{2}**

In this equation ‘Cost (s)’ is the cost of the slope, ‘s’ is the slope percentage, and ‘š’ is the critical slope value.

The critical slope value in this case has been set at 12%. This means the cost of climbing a slope this steep is twice as high as it is for those moving on flat terrain.

To calculate these in QGIS simply input this formula into the Raster Calculator. We can substitute ‘s’ with the slope raster (created using r.slope.aspect), and ‘š’ with ‘12’. This then gives us a cost surface for the study area where each cell has a unique cost value. There are over 6,000,000 in this one!

### Calculating cost distance

Cost distance is the accumulation of values from a cost surface when moving from point to point. As you move across the map your total cost is added together.

To work this out we use the **r.walk** function in GRASS. This takes the DEM and uses the values from the cells on the cost surface to plot the least cost distance. This results in the creation of two rasters. One that represents the total cost of movement (cumulative cost), the other the movement direction (to achieve a least cost path).

First, I worked out the cumulative cost for travelling from the site taking into account the slope. Then for comparison, I reprocessed the results without the cost of the slope.

### Least cost path (LCP)

Now we know the cost of travel from the site to other parts of the map, we need to know the most efficient path to take. To do this we use the **r.drain** function in GRASS. This uses the cumulative cost maps and the movement directions worked out in the previous step to trace a path from each of the nearby Roman forts back to our site.

And that’s all there is to know really. Least cost path analysis in a nutshell! Quite a fun little tool for working out paths across landscapes.

## One thought on “Cost paths across the Wolds, part 2”

Pleased I stuck with this. The technical detail is daunting at first but your blog gives a fascinating insight into the tools available online and how they can be used. Ready for more!