Dear R users,
I am trying to compute the least cost path between two points (A and B ) based on a transition matrix in R using the gdistance package. I have a resistance grid (resistance) with high cell values representing high resistance. My code so far is the following:
trCost <- transition(1/resistance,mean,directions = 8)
trCost <- geoCorrection(trCost)
sP <- shortestPath(trCost,A,B, output="SpatialLines")
However, shortly after I give the above commands, R displays the following error message:
Error in if (is.numeric(v) && any(v < 0)) { : missing value where TRUE/FALSE needed
Has anyone ever dealt with this issue before ? Any help will be greatly appreciated !