*et al.*2014), which would include most other geospatial Python packages. While scikit-image uses slightly different terminology, talking about "minimum cost paths" rather than "least-cost paths" as we tend to do in the geography/ecology world that I live in, on paper the approach looks identical to those commonly implemented in GIS software as it applies Dijkstra's algorithm with diagonal connectivity between cells. But before leaping into adopting this approach, I thought that while experimenting with scikit-image it would be wise to double-check that the results are the same as I would expect through more conventional GIS approaches, so I wrote some code:

```
# Import packages
import numpy as np
from skimage import graph
import nlmpy
# Set random seed so results are the same each time script runs
np.random.seed(1)
# Create a hypothetical cost-surface using the midpoint displacement method
cs = nlmpy.mpd(101, 101, h=1) * 5
# Make any values below one equal to no data
np.place(cs, cs < 1, -9999)
# Specify the size of the cell
cellSize = 10
# From the cost-surface create a 'landscape graph' object which can then be
# analysed using least-cost modelling
lg = graph.MCP_Geometric(cs, sampling=(cellSize, cellSize))
# Choose a starting cell location
startCell = (5, 5)
# Calculate the least-cost distance from the start cell to all other cells
lcd = lg.find_costs(starts=[startCell])[0]
# Export the data for comparison in GIS software
startGrid = np.zeros((101,101)) - 9999
startGrid[5,5] = 1
nlmpy.exportASCIIGrid("start.asc", startGrid, cellSize = 10)
nlmpy.exportASCIIGrid("cost-surface.asc", cs, cellSize = 10)
np.place(lcd, np.isinf(lcd), -9999) # insert no data values
nlmpy.exportASCIIGrid("least-cost-distances.asc", lcd, cellSize = 10)
```

```
# Import packages
import numpy as np
from skimage import graph
import time
import matplotlib.pyplot as plt
# Specify the cost-surface dimensions to process
dims = [100, 200, 400, 800, 1600, 3200, 6400]
# Create a list to hold results
times = []
# Process each cost-surface
for dim in dims:
print(dim)
# Create uniform cost-surface
cs = np.ones((dim, dim))
# Repeat 10 times and take mean time
repeats = 10
timeTaken = 0
for i in range(repeats):
print(i)
# Start clock
startTime = time.clock()
# Create landscape graph and calculate least-cost distance from corner
lg = graph.MCP_Geometric(cs)
lcd = lg.find_costs(starts=[(0,0)])[0]
# End clock
endTime = time.clock()
# Calculate time taken and append to results
timeTaken = timeTaken + (endTime - startTime)
times.append(timeTaken / repeats)
# Plot results
plt.scatter(dims, times)
plt.show()
```

**References**

van der Walt S, SchĂ¶nberger JL, Nunez-Iglesias J, Boulogne F, Warner JD, Yager N, Gouillart E, Yu T, Scikit Image Contributors (2014) scikit-image: image processing in Python. PeerJ 2:e453.