Align a SpatExtent
align.Rd
Align an SpatExtent 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).
It is also possible to align a SpatExtent to a clean divisor.
Usage
# S4 method for class 'SpatExtent,SpatRaster'
align(x, y, snap="near")
# S4 method for class 'SpatExtent,numeric'
align(x, y)
Examples
r <- rast()
e <- ext(-10.1, 9.9, -20.1, 19.9)
ea <- align(e, r)
e
#> SpatExtent : -10.1, 9.9, -20.1, 19.9 (xmin, xmax, ymin, ymax)
ext(r)
#> SpatExtent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
ea
#> SpatExtent : -10, 10, -20, 20 (xmin, xmax, ymin, ymax)
align(e, 0.5)
#> SpatExtent : -10.5, 10, -20.5, 20 (xmin, xmax, ymin, ymax)