Skip to content

gdistance::shortestPath throws error "not a symmetric matrix"

2 messages · Loris Bennett, Daniel Knitter

#
Hi,

Before I try to construct a reproducible example, which would probably
be quite time consuming, I wondered if this is a known problem.  I am
calling 'shortestPath' thus


  shortestPath(conduct_Tobler,
               origin = sites at coords[1,],
               goal = sites at coords[2,],
               output="SpatialLines")

and get the error

  Error in asMethod(object) :
    not a symmetric matrix; consider forceSymmetric() or symmpart()

with the following traceback:

  pairlist("stop(\"not a symmetric matrix; consider forceSymmetric() or
  symmpart()\")",
    "asMethod(object)",
    "as(Laplacian,\"symmetricMatrix\")",
    ".Laplacian(x)", ".flowMap(x, ci, cj, tc)",
    ".local(x, origin, goal, ...)",
  c("passage(conduct_Tobler, origin =sites at coords[5, ], goal =
  sites at coords[3, ", " ])"),
  c("passage(conduct_Tobler, origin = sites at coords[5, ], goal =
  sites at coords[3, ", " ])"),
    "eval(ei, envir)", "eval(ei, envir)",
    "withVisible(eval(ei, envir))",
    "source(\"./Skript.R\")")

However, a shape file is produced.

Any ideas what the problem might be?

Cheers,

Loris

--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universit?t Berlin         Email loris.bennett at fu-berlin.de
#
Hi Loris,

Tobler is an asymmetric function [as long as you used this one: function(s){6 * exp(-3.5 * abs(s + 0.05))} 

Did you create a symmetric transition object by calling 

"transition(InputRaster, TransitionFuncion, Neighborhood, symm=TRUE)"

This would explain the warning, because you need to set "symm=FALSE". symm=TRUE is only needed for random walks (i.e. passage function).

Cheers,
Daniel

On Tue, 06 Feb 2018 16:28:16 +0100
"Loris Bennett" <loris.bennett at fu-berlin.de> wrote: