R:删除使用splitRaster创建的栅格图块的重叠部分

时间:2019-01-23 15:54:56

标签: r raster overlap

我使用splitRaster库中的函数SpaDES创建了栅格图块:

set.seed(123)
# Create a matrix with random data
xy <- matrix(rnorm(400),20,20)

# Turn the matrix into a raster
rast <- raster(xy)
# Give it lat/lon coords for 39-42°E, 12-10°S
extent(rast) <- c(39,42,-12,-10)
# assign a projection
projection(rast) <- CRS("+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs")

# split it into 4 tiles and add an overlap (buffer) of one cell in x and one in y-direction
library(SpaDES)
split_rast <- splitRaster(r = rast, nx = 2, ny = 2, buffer = c(1,1))

# save the tile in tif format "GTiff"
tile_name <- c("1", "2", "3", "4")

for (i in 1:length(tile_name)) {

  writeRaster(split_dhm[[i]], filename = paste0("path\\tile",tile_name[i],".tif"), 
          format = "GTiff")

}

实际上,我的栅格不是矩形的,大小超过3 GB。 将单个文件(仍然很大)保存为tif之后,我使用RSAGA处理了它们以计算例如曲率:

for (i in 1:length(tile_name)) {

  rsaga.slope.asp.curv(in.dem = paste0("path\\tile", tile_name[i], ".tif"), 
                       out.cgene = paste0("path\\general_curvature_tile", 
                                          tile_name[i]),
                       env = work_env)

}

然后我使用raster重新加载了它:

path_name <- c("path\\tile1.sdat", "path\\tile2.sdat", "path\\tile3.sdat", "path\\tile4.sdat")
rasterlayer <- list()

for (i in 1:length(path_name)) {

  rasterlayer[[i]] <- raster(paste0(path_name[i]))

}

如何删除每个图块中的重叠部分?

0 个答案:

没有答案