Split rasters
Details
Splits a SpatRaster
up into a grain^2
list of approximately equal
geographic sized rasters covering the extent of x
Examples
# Split a raster into four
library(terra)
r <- example_raster()
s <- split_rast(r, grain = 2)
s
#> [[1]]
#> class : SpatRaster
#> dimensions : 5, 5, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 5, 0, 5 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : example
#> min value : 0.1587361
#> max value : 7.3352526
#>
#> [[2]]
#> class : SpatRaster
#> dimensions : 5, 5, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 5, 5, 10 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : example
#> min value : 0.1028045
#> max value : 4.0001839
#>
#> [[3]]
#> class : SpatRaster
#> dimensions : 5, 5, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 5, 10, 0, 5 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : example
#> min value : 0.09802478
#> max value : 3.23820739
#>
#> [[4]]
#> class : SpatRaster
#> dimensions : 5, 5, 1 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 5, 10, 5, 10 (xmin, xmax, ymin, ymax)
#> coord. ref. :
#> source(s) : memory
#> name : example
#> min value : 0.0627102
#> max value : 5.7145289
#>
# plot with original
ps <- lapply(
s,
FUN = extend,
y = r
) |>
rast()
c(r, ps) |> plot()