Learn R Programming

terra (version 0.4-3)

align: Align a SpatExtent with a SpatRaster

Description

Align an SpatExtent object with a SpatRaster. This can be useful to create a new SpatRaster with the same origin and resolution as an existing SpatRaster. Do not use this to force data to match that really does not match (use e.g. resample or (dis)aggregate for this).

Usage

# S4 method for SpatExtent,SpatRaster
align(x, y, snap="near", ...)

Arguments

x

SpatExtent

y

SpatRaster

snap

Character. One of "near", "in", or "out", to determine in which direction the extent should be aligned. To the nearest border, inwards or outwards

...

additional arguments. None implemented

Value

SpatExtent

See Also

ext, draw

Examples

Run this code
# NOT RUN {
r <- rast()
e <- ext(-10.1, 9.9, -20.1, 19.9)
ea <- align(e, r)
e
ext(r)
ea
# }

Run the code above in your browser using DataLab