terra (version 0.3-7)

extend: Extend

Description

Extend returns an SpatRaster object with a larger spatial extent. See crop if you (also) want to remove rows or columns.

There is also an extend method for Extent objects to enlarge (or app) an Extent. You can also use algebraic notation to do that (see examples)

Usage

# S4 method for SpatRaster
extend(x, y, filename="", overwrite=FALSE, wopt=list(), ...) 

# S4 method for SpatExtent extend(x, y, ...)

Arguments

x

SpatRaster or SpatExtent

y

If x is a SpatRaster, y should be a SpatExtent, or an object from which it can be extracted (such as SpatRaster and Spatvector objects). Alternatively, you can provide a numeric vector of length 2 indicating the number of rows and columns that need to be added (or a single number when the number of rows and columns is equal)

If x is an Extent object, y should be a numeric vector of 1, 2, or 4 elements

filename

character. Output filename. Optional

overwrite

logical. If TRUE, filename is overwritten

wopt

list. Options for writing files as in writeRaster

...

additional arguments. None implemented

Value

SpatRaster or SpatExtent

See Also

crop, merge

Examples

Run this code
# NOT RUN {
r <- rast(xmin=-150, xmax=-120, ymin=30, ymax=60, ncol=36, nrow=18)
values(r) <- 1:ncell(r)
e <- ext(-180, -100, 40, 70)
re <- extend(r, e)

# extend with a number of rows and columns (at each side)
re2 <- extend(r, c(2,10))

# Extent object
e <- ext(r)
e
extend(e, 10)
extend(e, 10, -10, 0, 20)
#e + 10
#e * 2
# }

Run the code above in your browser using DataLab