Skip to contents

Tests whether x shares the same CRS, extent, resolution, and origin as ref. A named logical vector is returned (invisibly) with one element per property. Mismatches trigger an informative message so callers can decide whether to harmonize before proceeding.

Usage

check_alignment(x, ref = ab_grid(), tol = 1e-06, verbose = TRUE)

Arguments

x

A SpatRaster (terra) or sf object to check.

ref

A SpatRaster used as the reference grid. Defaults to the ABMI 1 km Alberta grid, ab_grid().

tol

Numeric tolerance used for extent, resolution, and origin comparisons. Defaults to 1e-6.

verbose

Logical; if TRUE (default), messages are printed for each property.

Value

A named logical vector (invisible) with elements crs, extent, resolution, and origin. TRUE indicates agreement with ref.

Examples

if (FALSE) { # \dontrun{
library(terra)
ref <- rast(nrows = 10, ncols = 10, crs = "EPSG:3400")
r   <- rast(nrows = 10, ncols = 10, crs = "EPSG:4326")
check_alignment(r, ref)

# Against the default ABMI 1 km Alberta grid
check_alignment(r)
} # }