Hello Melanie,

It's really hard to tell what your problem is with no error message or reproducible example.

However here some info that may help and some trick to help you figure out the problem

First, gdistance build a transition matrix from a CONDUCTANCE matrix which is not a COST matrix like ArcGIS.  Therefore you initial raster should be 0 for land (no conductance) and 1 for water (conductance) and not 1 for water and 999 for land.

Second, I recently had trouble with shortestPath() when the shortest path involve to much of a detour.  So you should try first with too simple points where is not too hard to find the shortest path.

Plot your transition matrix "transi" with plot(raster(transi)) and add your point to it with points(x,y), it will help you see if your trying to do something that make sense.

Don't forget the geoCorrection(), it was necessary for me.

Good luck,

Bastien Ferland-Raymond, M.Sc. Stat., M.Sc. Biol.
Division des orientations et projets spéciaux
Direction des inventaires forestiers
Ministère des Ressources naturelles et de la Faune



	[[alternative HTML version deleted]]

