我正在尝试在1000平方米(50m x 20m)的田地上绘制可可产量图(每棵可可树的豆荚数量)。但是,当我尝试拟合方差图时,会收到以下消息:
警告信息: 在fit.variogram(object = PbVar,model = sph.model)中: 变异函数拟合的奇异模型
然后执行krige时,这是我收到的错误消息:
load.variogram.model(object $ model [[name]],c(i-1,i-1),max_dist = max_dist)中的错误: 变异函数范围永远不能为负
出什么问题了,我该如何拟合方差图使其呈正值,然后才能做克里格曲线?还是应该使用其他软件包中的其他空间插值功能?我必须在25个领域中进行这项工作,并且在1000m²的所有领域中都遇到了同样的问题。
谢谢。
library(readxl)
D02<-read_excel("D:/Mes Donnees)/R/stat2/D02.xlsx", col_names=T, na="")
library(sp)
library(gstat)
library(automap)
coordinates(D02) <- ~X+Y
spplot(D02,"yield",colorkey=TRUE)
bubble(D02, "yield",col=c("#00ff0088", "#00ff0088"), main = "rdt(cabosses)")
## creating a specific grid of 50m x 20m
min_x = min(D02$X)
min_y = min(D02$Y)
x_length = max(D02$X - min_x)
y_length = max(D02$Y - min_y)
cellsize = 1
ncol = round(x_length/cellsize,0)
nrow = round(y_length/cellsize,0)
grid = GridTopology(cellcentre.offset=c(min_x,min_y),
cellsize=c(cellsize,cellsize),cells.dim=c(ncol,nrow))
grid = SpatialPixelsDataFrame(grid,data=data.frame(id=1:prod(ncol,nrow)))
plot(grid)
PbVar <- variogram(yield~1, D02)
summary(PbVar)
plot(PbVar,pch=20,cex=1.5,col="black",ylab=expression("Semivariance ("*gamma*")"), xlab="Distance (m)", main = "yield")
sph.model <- vgm(psill=1739,"Sph",range=50, kappa=10)
sph.fit <- fit.variogram(object = PbVar,model=sph.model)
plot(PbVar,pch=20,cex=1.5,col="black",ylab=expression("Semivariance ("*gamma*")"),xlab="Distance (m)", main = "Cocoa yield (number of pods per cocoa tree)",model=sph.fit)
PbSph <- krige(yield~1, D02, grid, model = sph.fit)