set_window {geotargets}R Documentation

Copy a raster within a window

Description

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.

Usage

set_window(raster, window)

Arguments

raster

a SpatRaster object.

window

a SpatExtent object defining the area of interest.

Value

SpatRaster

Note

While this may have general use, it was created primarily for use within tar_terra_tiles().

Author(s)

Eric Scott

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)
terra::ext(r2)


[Package geotargets version 0.3.0 Index]