我只想从 float32 转换为 16b,比例因子为 10。我应该得到大小为 507kb(720*360*2)而不是 131kb 的文件。有什么帮助吗?
dir1 <- list.files("C:\\New folder (13)", "*.img", full.names = TRUE)
results <- list()
for (.files in seq_along(dir1)){
file2 <- readBin(dir1[.files], double(), size = 4, n = 360*720, signed = TRUE)
results[[length(results) + 1L]] <- file2[file2 != -9999]*10
fileName <- sprintf("C:\\SWdown_200001_%d.bin", .files)
writeBin(as.integer(results[[.files]]), fileName, size = 2)
}