Learn R Programming

terra (version 0.9-8)

window: Set a window

Description

Assign a window (area of interest) to a SpatRaster with a SpatExtent, or set it to NULL to remove the window. This is similar to crop and/or expand, without actually creating a new dataset.

Usage

# S4 method for SpatRaster
window(x, ...)<-value

Arguments

x

SpatRaster

value

SpatExtent

...

additional arguments. None implemented

See Also

crop, extend

Examples

Run this code
# NOT RUN {
f <- system.file("ex/test.tif", package="terra") 
r <- rast(f)
global(r, "mean", na.rm=TRUE)
e <- ext(c(179680, 180176, 331905, 332304))

window(r) <- e
global(r, "mean", na.rm=TRUE)
r

window(r) <- NULL
r


# }

Run the code above in your browser using DataLab