I am trying to do kriging by
gstat package through R.
Here is my Code:
krg<-krige(var ~ 1,data,grid,model=vgm,nmax=30)
But each time I recive this warning:
1: In predict.gstat(g, newdata = newdata, block = block, ... : Warning: Covariance matrix (nearly) singular at location [1,4501,0]: skipping...
and when I try to plot it by
spplot this error appears:
Error in seq.default(zrng, zrng, length.out = cuts + 2) : 'from' cannot be NA, NaN or infinite In addition: Warning messages: 1: In asMethod(object) : complete map seems to be NA's -- no selection was made 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf
Here is the full code: You can download my data through this link: Mydata and here is my full code:
library(gstat) library(sp) library(raster) coordinates(Mydata) <- ~East + North proj4string(Mydata) <- CRS("+proj=utm +zone=10+datum=WGS84") ext <- as(extent(Mydata), "SpatialPolygons") r <- rasterToPoints(raster(ext), spatial = TRUE) proj4string(r) <- proj4string(Mydata) v1 <- variogram(cpue_female ~ 1, Mydata) vgm_mod_omni <- vgm(psill = 0.0003, model = "Mat", range = 50000, nugget = 33, kappa = 0.5) G1 <- krige(cpue_female ~ 1, Mydata, r, vgm_mod_omni, nmax = 30) gridded(G1) <- TRUE spplot(G1)