Create a new SpatRaster object as specified by a window (area of interest)
over the original SpatRaster. This is a wrapper around terra::window()
which, rather than modifying the SpatRaster in place, returns a new
SpatRaster leaving the original unchanged.
Note
While this may have general use, it was created primarily for use
within tar_terra_tiles()
.
Examples
f <- system.file("ex/elev.tif", package="terra")
r <- terra::rast(f)
e <- terra::ext(c(5.9, 6,49.95, 50))
r2 <- set_window(r, e)
terra::ext(r)
#> SpatExtent : 5.74166666666667, 6.53333333333333, 49.4416666666667, 50.1916666666667 (xmin, xmax, ymin, ymax)
terra::ext(r2)
#> SpatExtent : 5.9, 6, 49.95, 50 (xmin, xmax, ymin, ymax)