extend | R Documentation |
Enlarge the spatial extent of a SpatRaster. See crop
if you (also) want to remove rows or columns.
You can also enlarge a SpatExtent with this method, or with algebraic notation (see examples)
## S4 method for signature 'SpatRaster' extend(x, y, snap="near", fill=NA, filename="", overwrite=FALSE, ...) ## S4 method for signature 'SpatExtent' extend(x, y)
x |
SpatRaster or SpatExtent |
y |
If If |
snap |
character. One of "near", "in", or "out". Used to align |
fill |
numeric. The value used to for the new raster cells |
filename |
character. Output filename |
overwrite |
logical. If |
... |
additional arguments for writing files as in |
SpatRaster or SpatExtent
crop
, merge
, ext
r <- rast(xmin=-150, xmax=-120, ymin=30, ymax=60, ncols=36, nrows=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)) # SpatExtent e <- ext(r) e extend(e, 10) extend(e, c(10, -10, 0, 20))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.