R/window.R

setMethod("window<-", signature(x="SpatRaster"),
	function(x, value)  {
		if (inherits(value, "SpatExtent")) {
			value <- value * ext(x)
			if (!(x@cpp$setWindow(value@cpp))) {
				error("window<-,SpatRaster", "could not set window")
			}
			#warn("window<-", "using a window is experimental")
		} else if (is.null(value) || is.na(value)) {
			x@cpp$removeWindow()
		} else {
			error("window<-", "'value' should be a SpatExtent, NULL or NA")
		}
		x
	}
)


setMethod("window", signature(x="SpatRaster"),
	function(x)  {
		x@cpp$hasWindow()
	}
)

Try the terra package in your browser

Any scripts or data that you put into this service are public.

terra documentation built on Oct. 13, 2023, 5:08 p.m.