I have a spatraster collection at 1-km resolution covering the entire globe. I want to split the spatraster into 6 (or any number) of equally sized spatraster
The below code splits the raster by layer but not spatially
library(terra)
s <- rast(system.file("ex/logo.tif", package="terra"))
s
class : SpatRaster
dimensions : 77, 101, 3 (nrow, ncol, nlyr)
resolution : 1, 1 (x, y)
extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax)
coord. ref. : Cartesian (Meter)
source : logo.tif
colors RGB : 1, 2, 3
names : red, green, blue
min values : 0, 0, 0
max values : 255, 255, 255
y <- terra::split(s, c(1,2,3))
y # 3 layers. But I want to split it spatially not by layer
You can use
terra::makeTiles(or write your own loop that callsterra::crop).For example, to split
sin 6 tiles, you could doYou can combine tiles with
terra::vrt