我遇到了运行 1000 次没有错误的代码的问题。
错误信息:
"Error in bb[, "max"] : subscript out of bounds"
我不知道bb是什么意思。我想bbox
,但这对于网格和点来说是一样的。
代码:
setwd("C:/Users/matev/desktop/")
getwd()
remove(list=ls())
library(gstat)
library(rgdal)
library(lattice)
#input data
DF<-read.csv(file="UpperRukaragata.csv", sep=",", dec=".", header=T)
str(DF)
plot(DF$X,DF$Y, col=DF$Z, cex=11, pch=14)
coordinates(DF)<-~X+Y
str(DF)
summary(DF$Ta2O5)
plot(DF)
# grid
x.range <- as.integer(range(DF@coords[,1]))
y.range <- as.integer(range(DF@coords[,2]))
str(x.range)
grd<-expand.grid(x=seq(from=x.range[1]+2.5, to=x.range[2]-2.5, by=5), y=seq(from=y.range[1]+2.5, to=y.range[2]-2.5, by=10))
coordinates(grd)<-~x+y
gridded(grd)<-T
plot(grd)
dimnames(coordinates(DF))
dimnames(coordinates(grd))
dimnames(grd@coords) <-list(NULL,c("X", "Y"))
dimnames(grd@bbox) <-list(c("X", "Y"))
bbox(DF)
bbox(grd)
#variogram Z
v1<-variogram (Ta2O5~1, loc=DF)
plot(v1, type="p", plot.numbers=F, cex=0.65, pch=16)
vm1<-vgm(70, "Pen",70, 0)
(vmf1<-fit.variogram(v1, vm1))
print(plot(v1, plot.numbers = F, pch = 20, col = "darkblue", model = vmf1))
##ordinary kriging
Ta2O5<-krige(Ta2O5~1, DF, grd, model=vmf1 )
如何解决这个问题呢?