View source: R/spatial_tools.R
update_extent | R Documentation |
extent
objectThis function updates a raster
's extent
by shrinking or expanding the x and y limits.
update_extent(x, x_shift, y_shift = x_shift)
x |
An |
x_shift |
A number that defines the change in the x limits. Positive numbers increase the extent (i.e., the lower limit is reduced and the upper limit is increased) while negative numbers reduce extent (i.e., the lower limit is increased and the upper limit is decreased). |
y_shift |
A number that defines the change in the y limits. By default, this equals |
The function returns an updated extent
object.
Edward Lavender
# Define example raster
r <- raster::raster(
nrows = 3, ncols = 3,
resolution = c(5, 5),
ext = raster::extent(0, 15, 0, 15)
)
# Increase raster extent by 5 units in every direction
update_extent(r, 5)
# Decrease raster extent by 5 units in every direction
update_extent(r, -5)
# Increase x and y extent parameters differently
update_extent(r, 5, 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.