alignExtent.Rd
Align an Extent object with the (boundaries of the) cells of a Raster* object
alignExtent(extent, object, snap='near')
Extent object
Aligning an Extent object to another object assures that it gets the same origin and resolution. This should only be used to adjust objects because of imprecision in the data. alignExtent should not be used to force data to match that really does not match (use e.g. resample
or (dis)aggregate for this).
r <- raster()
e <- extent(-10.1, 9.9, -20.1, 19.9)
ea <- alignExtent(e, r)
e
#> class : Extent
#> xmin : -10.1
#> xmax : 9.9
#> ymin : -20.1
#> ymax : 19.9
extent(r)
#> class : Extent
#> xmin : -180
#> xmax : 180
#> ymin : -90
#> ymax : 90
ea
#> class : Extent
#> xmin : -10
#> xmax : 10
#> ymin : -20
#> ymax : 20