【发布时间】:2019-08-27 15:13:03
【问题描述】:
我想在一个目录中采样栅格并移动到一个新的 (train) 并创建另一个未采样的栅格 (test1)。
为此我做了:
library(raster)
# Example data
r <- raster(ncol=10, nrow=10)
# 10 layers
s <- stack(lapply(1:10, function(i) setValues(r, runif(ncell(r)))))
#Create GeoTIFF for each layer
sl<-1:10
for (i in 1:length(sl)){
writeRaster(s[[i]],filename=paste(sl[i],sep=""),
format="GTiff",datatype="FLT4S",overwrite=TRUE)
}
#Imagens crete in batch
f <- list.files(getwd(), pattern = ".tif")
ras <- lapply(f,raster)
#Sample 80% of images for calibration
rasS<-sample(ras,round(length(ras)*0.8,digits=0))
dir.create("train")
file.copy(list.files(rasS),"train")
Error in list.files(rasS) : invalid 'path' argument
#Not sample images - 20%
rasT<- ras[ras!=rasS]
Error in ras != rasS : comparison of these types is not implemented
In addition: Warning message:
In ras != rasS :
longer object length is not a multiple of shorter object length
dir.create("test1")
file.copy(list.files(rasT),"train")
我必须解决问题,首先,我的 rasS 列表是无效的“路径”参数,并且 != 参数不适用于非样本栅格选择。有什么想法,请!
【问题讨论】: