NetworkX provides a ready-to-use library for the A* Algorithm.
Basically the steps you want to take are:
- Read the slope (the slope numbers are the weight, the more weight the less optimal)
- Create a graph from the slope matrix. This is the hardest part.
- 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 ;) )