Hello all,
Has anyone come across this error "CHOLMOD factorization was
unsuccessful" when using the resistance distance function in the new
package gdistance? I appreciate the help, this forum is really allowing me
to get past these issues.

#Read in the coordinates
> head(cord)
  coords.x1 coords.x2
0 -73.36111  6.810003
1 -73.45474  6.464962
2 -76.28194  1.137222
3 -76.40000  1.113333
4 -76.53278  1.233056
5 -76.27610  1.600061
> class(cord)
[1] "matrix"

#Read in the elevation raster
elevr<-raster("D:/Ben/GIS/Data/DimDiv/StudyArea_1km")

>Elevr
class       : RasterLayer
dimensions  : 2047, 1648, 3373456  (nrow, ncol, ncell)
resolution  : 0.007821463, 0.007821462  (x, y)
extent      : -80.82072, -67.93095, -4.788296, 11.22224  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
+towgs84=0,0,0
values      : D:\Ben\GIS\Data\DimDiv\StudyArea_1km
min value   : 1
max value   : 6169

#create a friction surface, i've also tried directions = 4
tmean<-transition(elevr, transitionFunction = mean, directions=8)

> tmean
class       : TransitionLayer
dimensions  : 2047, 1648, 3373456  (nrow, ncol, ncell)
resolution  : 0.007821463, 0.007821462  (x, y)
extent      : -80.82072, -67.93095, -4.788296, 11.22224  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
+towgs84=0,0,0
values      : conductance
matrix class: dsCMatrix

#perform the geocorrection (i've also tried skipping this step)
resistancesurface <- geoCorrection(tmean, type = "r", multpl = FALSE)


> resistancesurface
class       : TransitionLayer
dimensions  : 2047, 1648, 3373456  (nrow, ncol, ncell)
resolution  : 0.007821463, 0.007821462  (x, y)
extent      : -80.82072, -67.93095, -4.788296, 11.22224  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
+towgs84=0,0,0
values      : conductance
matrix class: dsCMatrix

#Get matrix of resistance distances.
> randomwalk<-resistanceDistance(resistancesurface,cord)
Error in Cholesky(Lr) : CHOLMOD factorization was unsuccessful
In addition: Warning message:
In Cholesky(Lr) :
  Cholmod warning 'not positive definite' at
file:../Cholesky/t_cholmod_rowfac.c, line 432
>

It's a bit difficult to parse. This process works perfectly for the
costDistance function, which is much prettier than the one i wrote in
python.

And while i'm at it, has anyone had a chance to create a matrix of pairwise
shortest paths? That is the distance of the least cost path from every
combination of sites. My first thought is:

pathloop<- function(coord,origin) sapply(coord, function(x)
shortestPath(meansurface, coord[origin], coord[x,], output="SpatialLines")

and then loop that through a 2nd apply loop for each origin point.

As always, i appreciate the help.

Ben Weinstein

-- 
Ben Weinstein
Graduate Student
Ecology and Evolution
Stony Brook University

http://life.bio.sunysb.edu/~bweinste/index.html

        [[alternative HTML version deleted]]

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

Reply via email to