[R-sig-Geo] gdistance, shortest path => "cannot derive coordinates from non-numeric matrix"

Jacob van Etten jacobvanetten at yahoo.com
Thu Aug 11 22:44:55 CEST 2011


Dear Mathieu,

From what I can see, the error is not due to the TransitionLayer, but is about the coordinates.

The following code works with the versions of gdistance and raster that are currently on CRAN (gdistance_1.1-1, raster_1.9-5):

library(gdistance)
rognes.r <- raster(nrows=50, ncols=50, xmn=887000, xmx=892000, ymn=6285000, ymx=6290000, crs="+proj=utm +zone=31")
rognes.r[] <- 1
rognes.t = transition(rognes.r, transitionFunction = mean, directions=8)
A = c(887543,6286048)
B = c(890911,6289681)
path = shortestPath(rognes.t, A, B, output="SpatialLines")

Next time, provide the results of sessionInfo() when you post to this list. Also, try to provide reproducible code (like in my example). With the information you give now, I can only guess the cause of your problem.

Jacob

--- On Thu, 11/8/11, Mathieu Rajerison <mathieu.rajerison at gmail.com> wrote:

> From: Mathieu Rajerison <mathieu.rajerison at gmail.com>
> Subject: [R-sig-Geo] gdistance, shortest path => "cannot derive coordinates from non-numeric matrix"
> To: r-sig-geo at r-project.org
> Date: Thursday, 11 August, 2011, 17:59
> Hi,
> 
> 
> I'm using gdistance to  determine optimal wildlife
> corridors. My transition
> layer's name is rognes.t, rognes being a city  name.
> 
> I want to determine a corridor between two major ecologic
> niches with
> centroids coordinates A and B.
> 
> But when launching shortestPath, i get the following
> error:
> > rognes.t = transition(rognes.r, transitionFunction =
> mean, directions=8)
> > A = c(887543,6286048)
> > B = c(890911,6289681)
> > path = shortestPath(rognes.t, A, B,
> output="SpatialLines")
> Erreur dans .local(obj, ...) :
> cannot derive coordinates from non-numeric matrix
> De plus : Message d'avis :
> In get.shortest.paths(adjacencyGraph, indexOrigin,
> indexGoal) :
> At structural_properties.c:42
> 
> My transitionMatrix has these characteristics:
> > min(transitionMatrix(rognes.t));
> max(transitionMatrix(rognes.t));
> mean(transitionMatrix(rognes.t))
> [1] 0
> [1] 100
> [1] 0.0009044702
> 
> All values are numeric..
> 
> 
> Any help would be greatly appreciated,
> 
> mathieu
> 
>     [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list