Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cholmod error 'index out of range' at file ../core/cholmo d_triplet.c, line 451 #12

Open
mguzmann opened this issue May 7, 2022 · 4 comments

Comments

@mguzmann
Copy link

mguzmann commented May 7, 2022

I am getting this error when working with very large rasters.

h.dist <- gdistance::transition(DEM, transitionFunction = function(x){1}, directions = 8, symm = TRUE)
h.dist <- gdistance::geoCorrection(h.dist, scl = FALSE)
adj <- raster::adjacent(DEM, cells = 1:ncell(DEM), pairs = TRUE, directions = 8)
h.dist[adj] <- 1/h.dist[adj]

The error comes from the last line:

h.dist[adj] <- 1/h.dist[adj]

If I do something like:

h.dist[tail(adj)] <- 1/h.dist[tail(adj)]

or

h.dist[adj[1:10,]] <- 1/h.dist[adj[1:10,]]

It works fine. The adj matrix has 1164557166 rows, so I don't know whether there is a hard limit on the indexing that can be handled by sparse matrices?

I guess I can do a for loop and process it in chunks, would that work?

@mguzmann
Copy link
Author

mguzmann commented May 7, 2022

It seems like it is one specific entry:

h_t[matrix(c(145589643, 145589644), ncol = 2)] <- 1

Produces:

Cholmod error 'index out of range' at file ../Core/cholmod_triplet.c, line 451

Other pairs after that one don't cause issues.

@andrewmarx
Copy link
Contributor

Hi, I've started looking at this but might not have access to a machine with quite enough memory to reproduce it.

I know this is old, but could you update the gdistance, raster, terra, and Matrix packages and try running it again? They've seen significant updates over the last year and it's possible your issue was fixed in the process. It could save me a lot of effort trying to reproduce a problem that might not be a problem anymore.

@mguzmann
Copy link
Author

mguzmann commented Jun 4, 2023

Hi, thanks for looking into this. I don't currently have access to a similar server. I will try to reproduce this issue as soon as I do.

@mguzmann
Copy link
Author

It seems that one error is no longer there, but now after doing:

h.dist <- gdistance::transition(rst_na,
                                transitionFunction = function(x) {
                                  1
                                }, directions = 8, symm = TRUE
                                )
h.dist <- gdistance::geoCorrection(h.dist, scl = FALSE)
adj <- raster::adjacent(rst_na,
                        cells = 1:ncell(rst_na),
                        pairs = TRUE, directions = 8
                        )
h.dist[adj] <- 1/h.dist[adj]

elevDiff <- function(x) {
  1 * abs(x[2] - x[1])
}
v.dist <- gdistance::transition(rst_na, elevDiff, 8, symm = TRUE)
t.dist <- v.dist
t.dist[adj] <- 1/sqrt((h.dist[adj]^2) + (v.dist[adj]^2))

I can share rst_na (a raster for the whole of North America) if that helps.

(this is following the topoDistance function topoSurface, not sure if the issue is in that approach)

I get:

Error in ..subscript.1ary.mat(x, i) :
invalid class "dsCMatrix" object: uplo="U" but there are entries below the diagonal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants