我正在使用大型多波段光栅图像,为了避免超出系统内存,我尝试使用r栅格包中的writeStart / writeValues函数进行块处理。我从RasterBricks开始,但在分别处理每个乐队之后,它们变成了RasterStacks,我无法writeStop
它们,导出它们,或者将它们更改回RasterBricks,并且当我这样做时不断出现Error in .local(.Object, ...) :
错误。
简化代码:
test = brick("raster.TIF")
out = brick(test)
out = writeStart(out,"test.tif", format = "GTiff", overwrite=TRUE)
for(i in 1:test@file@nbands){
tr = blockSize(test)
for(j in 1:tr$n){
x = getValues(test[[i]], row = tr$row[j], nrows = tr$nrows[j])
x = x - min(x)
out[[i]] = writeValues(out[[i]], x, tr$row[j])
}
}
out = writeStop(out)
> out = writeStop(out)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘writeStop’ for signature ‘"RasterStack"’
> out = brick(out)
Error in .local(.Object, ...) :
所以我正在寻找任何解决方法或解决方案。 out = brick(out)
出现Error in .local(.Object, ...) :
错误。