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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Loris Bennett
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@coords[1,],
               goal = sites@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@coords[5, ], goal =
  sites@coords[3, ", " ])"),
  c("passage(conduct_Tobler, origin = sites@coords[5, ], goal =
  sites@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 [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

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

Daniel Knitter
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" <[hidden email]> wrote:

> 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@coords[1,],
>                goal = sites@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@coords[5, ], goal =
>   sites@coords[3, ", " ])"),
>   c("passage(conduct_Tobler, origin = sites@coords[5, ], goal =
>   sites@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 [hidden email]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--

Dr. Daniel Knitter
CRC1266 -- Scales of Transformation
Project A2 "Integrative Modeling of Socio-Environmental Dynamics"

Christian-Albrechts-Universität zu Kiel
Department of Geography
Physical Geography -- Landscape Ecology and Geoinformation
Ludewig-Meyn-Str. 14, room 109
D - 24118 Kiel, Germany

Phone: +49 431 880 2941
Email: [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

attachment0 (836 bytes) Download Attachment