The trim function from the terra package only remove cols and rows full of NA. This function remove all cols and rows with NA on the periphery. Useful to get a nicely formatted raster grid after reprojection.

trim_na(rast, verbose = F)

Arguments

rast

input raster (SpatRaster)

verbose

flag (default FALSE) to switch

Value

a trimmed raster (SpatRaster)