[NetworkX][1] provides a ready-to-use library for the A* Algorithm. Basically the steps you want to take are: 1. Read the slope (the slope numbers are the weight, the more weight the less optimal) 2. Create a **graph** from the slope matrix. This is the hardest part. 3. Feed the NetworkX lib the graph and according to docs it should do the rest. This is a canned solution imo. If you want to learn how the A* algorithm works you can create a T/F matrix, where T is the 'walkable' cells (with a slope less than 4?) and F the not walkables. There are many worth reading tutorials on the subject for the A* around the intertubes that operate with that kind of arrays. Good learning material! (That will be my weekend project ;) ) [1]: http://networkx.github.io/documentation/latest/reference/generated/networkx.algorithms.shortest_paths.astar.astar_path.html#networkx.algorithms.shortest_paths.astar.astar_path