[GIS] Gstat krige() error: Covariance matrix singular at location [917300,3.6109e+06,0]: skipping

interpolationkrigingrspatial statistics

Recently, I am facing a strange problem when using krige() in gstat library. This error was not there a few months ago because I am using the same code with the same data that I successfully used before. But now I am getting singular covariance matrix at grid points at which I want to krige the unknown values. I changed nothing in that old code. Just opened and ran, and now it would not run. Upon searching I found one solution set=list(cn_max = 1e10) from a communication between Edzer and Hengl under title "[R-sig-Geo] 'LDLfactor' error in 'krige' function". However, then krige() gives syntax error about cn_max. I also read "Error in In predict.gstat in R" question on this site, but it also does not work for me.

Why I am getting this error suddenly?

Best Answer

This is caused by the matrix library used by gstat. Historically (gstat was released as open source code in 1997) it used the LDLfactor routine in the meschach library. Around 6 months ago I factored this out this code and replaced it with the BLAS/LAPACK which are native in R. LAPACK uses Choleski decomposition. LDLfactor allows for some non-positive matrices, where Choleski will trigger an error on this.

So, your problem is apparently a non-positive definite matrix which was not detected by LDL, but was detected by Choleski.

Related Question